-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuiltin.js
More file actions
21 lines (18 loc) · 1.07 KB
/
builtin.js
File metadata and controls
21 lines (18 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
console.assert(Infinity, "Infinity");
console.assertEqual(Infinity, Infinity, "Infinity");
console.assert(NaN !== NaN, "NaN");
console.assertEqual(NaN, NaN, "NaN");
console.assertEqual(undefined, undefined, "undefined");
// Using an assignment operator on these properties of the global object should happily evaluate to
// the value you would expect, without _actually_ changing the value of the property.
assertUnmodifiable(function () { return Infinity; }, function (n) { return Infinity = n; }, "Infinity");
assertUnmodifiable(function () { return Infinity; }, function (n) { return Infinity = n; }, "Infinity");
assertUnmodifiable(function () { return NaN; }, function (n) { return NaN = n; }, "NaN");
assertUnmodifiable(function () { return undefined; }, function (n) { return undefined = n; }, "undefined");
function assertUnmodifiable(getter, setter, msg) {
let original = getter();
console.assertEqual(setter(42), 42, msg);
let hopefullyUnmodified = getter();
console.assertEqual(hopefullyUnmodified, original, msg);
console.assert(hopefullyUnmodified !== 42, msg);
}