Order of evaluation tests for infix numeric operators

This commit is contained in:
Josh Wolfe 2018-01-18 13:50:44 -07:00 committed by Rick Waldron
parent 186ec5d177
commit 9d066a8181
12 changed files with 1658 additions and 0 deletions

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");

View File

@ -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.");