| 1 |
// Copyright (C) 2015 André Bargull. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
info: Assignment Operator evaluates its operands from left to right. |
| 6 |
description: > |
| 7 |
The left-hand side expression is evaluated before the right-hand side. |
| 8 |
Left-hand side expression is MemberExpression: base[prop]. base is the |
| 9 |
undefined value. |
| 10 |
---*/ |
| 11 |
|
| 12 |
function DummyError() { } |
| 13 |
|
| 14 |
assert.throws(DummyError, function() { |
| 15 |
var base = undefined; |
| 16 |
var prop = function() { |
| 17 |
throw new DummyError(); |
| 18 |
}; |
| 19 |
var expr = function() { |
| 20 |
$ERROR("right-hand side expression evaluated"); |
| 21 |
}; |
| 22 |
|
| 23 |
base[prop()] = expr(); |
| 24 |
}); |
| 25 |
|
| 26 |
assert.throws(TypeError, function() { |
| 27 |
var base = undefined; |
| 28 |
var prop = { |
| 29 |
toString: function() { |
| 30 |
$ERROR("property key evaluated"); |
| 31 |
} |
| 32 |
}; |
| 33 |
var expr = function() { |
| 34 |
$ERROR("right-hand side expression evaluated"); |
| 35 |
}; |
| 36 |
|
| 37 |
base[prop] = expr(); |
| 38 |
}); |