diff --git a/test/language/expressions/addition/order-of-evaluation.js b/test/language/expressions/addition/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..103f82d5dc1868aed57aa82d99cf24e99a7739d3 --- /dev/null +++ b/test/language/expressions/addition/order-of-evaluation.js @@ -0,0 +1,140 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-addition-operator-plus-runtime-semantics-evaluation +description: Type coercion order of operations for addition operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToPrimitive(lhs) + ToPrimitive(rhs) + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() + (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() + (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() + (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() + (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToPrimive(rhs) is called before ?ToNumeric(lhs). +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() + (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) is called before ?ToNumeric(lhs)."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) is called before ?ToNumeric(lhs)."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() + (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/bitwise-and/order-of-evaluation.js b/test/language/expressions/bitwise-and/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..8aab592f6d3599071d84bfda3eee767197e353fd --- /dev/null +++ b/test/language/expressions/bitwise-and/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-binary-bitwise-operators-runtime-semantics-evaluation +description: Type coercion order of operations for bitwise-and operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() & (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() & (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() & (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() & (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() & (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() & (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/bitwise-or/order-of-evaluation.js b/test/language/expressions/bitwise-or/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..c1bd291d440b7f80c75fd76596eb8933218cf3f1 --- /dev/null +++ b/test/language/expressions/bitwise-or/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-binary-bitwise-operators-runtime-semantics-evaluation +description: Type coercion order of operations for bitwise-or operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() | (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() | (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() | (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() | (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() | (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() | (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/bitwise-xor/order-of-evaluation.js b/test/language/expressions/bitwise-xor/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..e790ef35b8bd2eab233e83009b97eb674f1cacdd --- /dev/null +++ b/test/language/expressions/bitwise-xor/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-binary-bitwise-operators-runtime-semantics-evaluation +description: Type coercion order of operations for bitwise-xor operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() ^ (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() ^ (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() ^ (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() ^ (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() ^ (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() ^ (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/division/order-of-evaluation.js b/test/language/expressions/division/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..80097fe34d6e92d62a73715b512641b4e45d0ffb --- /dev/null +++ b/test/language/expressions/division/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-multiplicative-operators-runtime-semantics-evaluation +description: Type coercion order of operations for division operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() / (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() / (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() / (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() / (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() / (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() / (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/exponentiation/order-of-evaluation.js b/test/language/expressions/exponentiation/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..93da0d99e92288b701430800bcfee0d60daeb10f --- /dev/null +++ b/test/language/expressions/exponentiation/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-exp-operator-runtime-semantics-evaluation +description: Type coercion order of operations for exponentiation operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() ** (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() ** (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() ** (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() ** (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() ** (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() ** (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/left-shift/order-of-evaluation.js b/test/language/expressions/left-shift/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..e682dad72989eafb74eeefc08ec2289e460ca969 --- /dev/null +++ b/test/language/expressions/left-shift/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-left-shift-operator-runtime-semantics-evaluation +description: Type coercion order of operations for left-shift operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() << (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() << (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() << (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() << (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() << (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() << (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/modulus/order-of-evaluation.js b/test/language/expressions/modulus/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..ac91c49d2700a90e7e7fbbfeaa5ff7ac87533c13 --- /dev/null +++ b/test/language/expressions/modulus/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-multiplicative-operators-runtime-semantics-evaluation +description: Type coercion order of operations for modulus operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() % (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() % (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() % (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() % (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() % (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() % (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/multiplication/order-of-evaluation.js b/test/language/expressions/multiplication/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..af612685aa3829117148f73dd3c7800e404fa4ef --- /dev/null +++ b/test/language/expressions/multiplication/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-multiplicative-operators-runtime-semantics-evaluation +description: Type coercion order of operations for multiplication operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() * (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() * (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() * (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() * (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() * (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() * (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/right-shift/order-of-evaluation.js b/test/language/expressions/right-shift/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..4630d988863ca4654512a40363995541ced1d88e --- /dev/null +++ b/test/language/expressions/right-shift/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-signed-right-shift-operator-runtime-semantics-evaluation +description: Type coercion order of operations for right-shift operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() >> (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() >> (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() >> (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() >> (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() >> (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() >> (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/subtraction/order-of-evaluation.js b/test/language/expressions/subtraction/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..62134d00172ea3e4456f84ef8f9cae2fafbb382f --- /dev/null +++ b/test/language/expressions/subtraction/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-subtraction-operator-minus-runtime-semantics-evaluation +description: Type coercion order of operations for subtraction operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() - (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() - (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() - (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() - (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() - (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() - (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws."); diff --git a/test/language/expressions/unsigned-right-shift/order-of-evaluation.js b/test/language/expressions/unsigned-right-shift/order-of-evaluation.js new file mode 100644 index 0000000000000000000000000000000000000000..f8eb9442e46a603a37569d4edd3f9d7623f7f705 --- /dev/null +++ b/test/language/expressions/unsigned-right-shift/order-of-evaluation.js @@ -0,0 +1,138 @@ +// Copyright (C) 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-unsigned-right-shift-operator-runtime-semantics-evaluation +description: Type coercion order of operations for unsigned-right-shift operator +features: [Symbol] +info: | + Evaluate lhs + Evaluate rhs + ToNumeric(lhs) + ToNumeric(rhs) +---*/ + +function MyError() {} +var trace; + +// ?GetValue(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + throw new MyError(); + })() >>> (function() { + trace += "2"; + throw new Test262Error("should not be evaluated"); + })(); +}, "?GetValue(lhs) throws."); +assert.sameValue(trace, "1", "?GetValue(lhs) throws."); + +// ?GetValue(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new Test262Error("should not be evaluated"); + } + }; + })() >>> (function() { + trace += "2"; + throw new MyError(); + })(); +}, "?GetValue(rhs) throws."); +assert.sameValue(trace, "12", "?GetValue(rhs) throws."); + +// ?ToPrimive(lhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + throw new MyError(); + } + }; + })() >>> (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToPrimive(lhs) throws."); +assert.sameValue(trace, "123", "?ToPrimive(lhs) throws."); + +// ?ToPrimive(rhs) throws. +trace = ""; +assert.throws(MyError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() >>> (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new MyError(); + } + }; + })(); +}, "?ToPrimive(rhs) throws."); +assert.sameValue(trace, "1234", "?ToPrimive(rhs) throws."); + +// ?ToNumeric(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return Symbol("1"); + } + }; + })() >>> (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + throw new Test262Error("should not be evaluated"); + } + }; + })(); +}, "?ToNumeric(lhs) throws."); +assert.sameValue(trace, "123", "?ToNumeric(lhs) throws."); + +// GetValue(lhs) throws. +trace = ""; +assert.throws(TypeError, function() { + (function() { + trace += "1"; + return { + valueOf() { + trace += "3"; + return 1; + } + }; + })() >>> (function() { + trace += "2"; + return { + valueOf() { + trace += "4"; + return Symbol("1"); + } + }; + })(); +}, "GetValue(lhs) throws."); +assert.sameValue(trace, "1234", "GetValue(lhs) throws.");