/* Values. */
- { njs_str("undefined"), NJS_TOKEN_UNDEFINED, 0 },
{ njs_str("null"), NJS_TOKEN_NULL, 0 },
{ njs_str("false"), NJS_TOKEN_BOOLEAN, 0 },
{ njs_str("true"), NJS_TOKEN_BOOLEAN, 1 },
- { njs_str("NaN"), NJS_TOKEN_NUMBER, NAN },
- { njs_str("Infinity"), NJS_TOKEN_NUMBER, INFINITY },
/* Operators. */
{ njs_str("MemoryError"), NJS_TOKEN_MEMORY_ERROR_CONSTRUCTOR, 0 },
/* Module. */
+
{ njs_str("import"), NJS_TOKEN_IMPORT, 0 },
{ njs_str("export"), NJS_TOKEN_EXPORT, 0 },
#if 0 /* TODO */
{ njs_str("var a; Object.getOwnPropertyDescriptor(this, 'a').value"),
njs_str("undefined") },
-
- { njs_str("this.a = 1; a"),
- njs_str("1") },
#endif
{ njs_str("f() = 1"),
{ njs_str("undefined + undefined"),
njs_str("NaN") },
+ { njs_str("var undefined"),
+ njs_str("undefined") },
+
{ njs_str("1.2 + 5.7"),
njs_str("6.9") },
{ njs_str("-Infinity >= Infinity"),
njs_str("false") },
+ { njs_str("Boolean(Infinity)"),
+ njs_str("true") },
+
+ { njs_str("!Infinity === false"),
+ njs_str("true") },
+
+ { njs_str("var Infinity"),
+ njs_str("undefined") },
+
+#if 0 /* ES5FIX */
+ { njs_str("Infinity = 1"),
+ njs_str("TypeError: Cannot assign to read-only property "Infinity" of object") },
+#endif
+
/**/
{ njs_str("NaN === NaN"),
{ njs_str("NaN <= NaN"),
njs_str("false") },
+ { njs_str("var NaN"),
+ njs_str("undefined") },
+
+#if 0 /* ES5FIX */
+ { njs_str("NaN = 1"),
+ njs_str("TypeError: Cannot assign to read-only property "NaN" of object") },
+#endif
+
/**/
{ njs_str("null < 0"),
{ njs_str("null = 1"),
njs_str("ReferenceError: Invalid left-hand side in assignment in 1") },
+#if 0 /* ES5FIX */
{ njs_str("undefined = 1"),
- njs_str("ReferenceError: Invalid left-hand side in assignment in 1") },
+ njs_str("TypeError: Cannot assign to read-only property "undefined" of object") },
+#endif
{ njs_str("null++"),
njs_str("ReferenceError: Invalid left-hand side in postfix operation in 1") },
{ njs_str("var o = { [new Number(12345)]: 1000 }; o[12345]"),
njs_str("1000") },
- /* ES5FIX: "SyntaxError". */
-
{ njs_str("delete NaN"),
- njs_str("true") },
-
- /* ES5FIX: "SyntaxError". */
+ njs_str("SyntaxError: Delete of an unqualified identifier in 1") },
{ njs_str("delete Infinity"),
- njs_str("true") },
+ njs_str("SyntaxError: Delete of an unqualified identifier in 1") },
{ njs_str("delete -Infinity"),
njs_str("true") },
{ njs_str("[0].some(function(){return Array.call.bind(isNaN)}())"),
njs_str("false") },
+ { njs_str("(function (undefined, NaN, Infinity){ return undefined + NaN + Infinity})('x', 'y', 'z')"),
+ njs_str("xyz") },
+
+ { njs_str("function f(undefined,NaN, Infinity){ return undefined + NaN + Infinity}; f('x', 'y', 'z')"),
+ njs_str("xyz") },
+
/* Recursive factorial. */
{ njs_str("function f(a) {"
{ njs_str("this.a = ()=>1; a()"),
njs_str("1") },
+ { njs_str("var global = this;"
+ "function isImmutableConstant(v) {"
+ " var d = Object.getOwnPropertyDescriptor(global, v);"
+ " return !d.writable && !d.enumerable && !d.configurable;"
+ "};"
+ "['undefined', 'NaN', 'Infinity'].every((v)=>isImmutableConstant(v))"),
+ njs_str("true") },
+
{ njs_str("this.undefined = 42"),
njs_str("TypeError: Cannot assign to read-only property \"undefined\" of object") },