summaryrefslogtreecommitdiff
path: root/test/language/expressions/compound-assignment/S11.13.2_A7.2_T2.js
diff options
context:
space:
mode:
authorAndré Bargull <andre.bargull@gmail.com>2015-05-09 12:33:04 +0200
committerAndré Bargull <andre.bargull@gmail.com>2015-05-18 18:12:25 +0200
commitc5e18d561cdea18973e49f70186767272993c51b (patch)
treede2d86e0674a268db1806865c14b3edb9fbf94ce /test/language/expressions/compound-assignment/S11.13.2_A7.2_T2.js
parentb56af07567959c7962f9d639f5791fa5c25b4c08 (diff)
downloadqtdeclarative-testsuites-c5e18d561cdea18973e49f70186767272993c51b.tar.gz
Assignment with left-hand side property accessor
The assignment operator evaluates its operands from left to right. When the left-hand side expression is a property accessor, RequireObjectCoercible and ToPropertyKey are called on the property accessor before the right-hand side expression is evaluated.
Diffstat (limited to 'test/language/expressions/compound-assignment/S11.13.2_A7.2_T2.js')
-rwxr-xr-xtest/language/expressions/compound-assignment/S11.13.2_A7.2_T2.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/language/expressions/compound-assignment/S11.13.2_A7.2_T2.js b/test/language/expressions/compound-assignment/S11.13.2_A7.2_T2.js
new file mode 100755
index 000000000..66bf3c369
--- /dev/null
+++ b/test/language/expressions/compound-assignment/S11.13.2_A7.2_T2.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Compound Assignment Operator evaluates its operands from left to right.
+description: >
+ The left-hand side expression is evaluated before the right-hand side.
+ Left-hand side expression is MemberExpression: base[prop]. base is the
+ undefined value.
+ Check operator is "x /= y".
+---*/
+
+function DummyError() { }
+
+assert.throws(DummyError, function() {
+ var base = undefined;
+ var prop = function() {
+ throw new DummyError();
+ };
+ var expr = function() {
+ $ERROR("right-hand side expression evaluated");
+ };
+
+ base[prop()] /= expr();
+});
+
+assert.throws(TypeError, function() {
+ var base = undefined;
+ var prop = {
+ toString: function() {
+ $ERROR("property key evaluated");
+ }
+ };
+ var expr = function() {
+ $ERROR("right-hand side expression evaluated");
+ };
+
+ base[prop] /= expr();
+});