From 5acd66e10ade6c1daea96d8b78d03a4760a2559e Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 7 Apr 2015 16:39:19 -0400 Subject: [PATCH 1/5] Rename test files According to the new test organization scheme, specification identification references should be encoded within the test file itself, and the file should be named according to the semantics of the test. --- test/language/expressions/typeof/{S11.4.3_A3.3.js => boolean.js} | 0 .../typeof/{S10.1.1_A2_T1.js => built-in-functions.js} | 0 .../expressions/typeof/{S11.4.3_A2_T1.js => get-value.js} | 0 .../expressions/typeof/{S11.4.3_A3.7.js => native-call.js} | 0 .../expressions/typeof/{S11.4.3_A3.6.js => native-no-call.js} | 0 test/language/expressions/typeof/{S11.4.3_A3.2.js => null.js} | 0 test/language/expressions/typeof/{S11.4.3_A3.4.js => number.js} | 0 test/language/expressions/typeof/{S11.4.3_A3.5.js => string.js} | 0 test/language/expressions/typeof/{S11.4.3_A1.js => syntax.js} | 0 .../language/expressions/typeof/{S11.4.3_A3.1.js => undefined.js} | 0 .../typeof/{S11.4.3_A2_T2.js => unresolvable-reference.js} | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename test/language/expressions/typeof/{S11.4.3_A3.3.js => boolean.js} (100%) rename test/language/expressions/typeof/{S10.1.1_A2_T1.js => built-in-functions.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A2_T1.js => get-value.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A3.7.js => native-call.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A3.6.js => native-no-call.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A3.2.js => null.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A3.4.js => number.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A3.5.js => string.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A1.js => syntax.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A3.1.js => undefined.js} (100%) rename test/language/expressions/typeof/{S11.4.3_A2_T2.js => unresolvable-reference.js} (100%) diff --git a/test/language/expressions/typeof/S11.4.3_A3.3.js b/test/language/expressions/typeof/boolean.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A3.3.js rename to test/language/expressions/typeof/boolean.js diff --git a/test/language/expressions/typeof/S10.1.1_A2_T1.js b/test/language/expressions/typeof/built-in-functions.js similarity index 100% rename from test/language/expressions/typeof/S10.1.1_A2_T1.js rename to test/language/expressions/typeof/built-in-functions.js diff --git a/test/language/expressions/typeof/S11.4.3_A2_T1.js b/test/language/expressions/typeof/get-value.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A2_T1.js rename to test/language/expressions/typeof/get-value.js diff --git a/test/language/expressions/typeof/S11.4.3_A3.7.js b/test/language/expressions/typeof/native-call.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A3.7.js rename to test/language/expressions/typeof/native-call.js diff --git a/test/language/expressions/typeof/S11.4.3_A3.6.js b/test/language/expressions/typeof/native-no-call.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A3.6.js rename to test/language/expressions/typeof/native-no-call.js diff --git a/test/language/expressions/typeof/S11.4.3_A3.2.js b/test/language/expressions/typeof/null.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A3.2.js rename to test/language/expressions/typeof/null.js diff --git a/test/language/expressions/typeof/S11.4.3_A3.4.js b/test/language/expressions/typeof/number.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A3.4.js rename to test/language/expressions/typeof/number.js diff --git a/test/language/expressions/typeof/S11.4.3_A3.5.js b/test/language/expressions/typeof/string.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A3.5.js rename to test/language/expressions/typeof/string.js diff --git a/test/language/expressions/typeof/S11.4.3_A1.js b/test/language/expressions/typeof/syntax.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A1.js rename to test/language/expressions/typeof/syntax.js diff --git a/test/language/expressions/typeof/S11.4.3_A3.1.js b/test/language/expressions/typeof/undefined.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A3.1.js rename to test/language/expressions/typeof/undefined.js diff --git a/test/language/expressions/typeof/S11.4.3_A2_T2.js b/test/language/expressions/typeof/unresolvable-reference.js similarity index 100% rename from test/language/expressions/typeof/S11.4.3_A2_T2.js rename to test/language/expressions/typeof/unresolvable-reference.js From 9c42c10e48325c0c1ba9c2c127fe306a58913e25 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 7 Apr 2015 17:07:30 -0400 Subject: [PATCH 2/5] Correct error in test descriptions --- test/language/expressions/typeof/built-in-functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/language/expressions/typeof/built-in-functions.js b/test/language/expressions/typeof/built-in-functions.js index f072707120..83ed31e636 100644 --- a/test/language/expressions/typeof/built-in-functions.js +++ b/test/language/expressions/typeof/built-in-functions.js @@ -11,8 +11,8 @@ description: Checking types of parseInt and Math.exp //CHECK#1 if(typeof(Math.exp)!=="function") - $ERROR('#1: typeof(Math.exp(10))!=="function" '+typeof(Math.exp())); + $ERROR('#1: typeof(Math.exp)!=="function" '+typeof(Math.exp)); //CHECK#2 if(typeof(parseInt)!=="function") - $ERROR('#2: typeof(parseInt())!=="function" '+typeof(parseInt())); + $ERROR('#2: typeof(parseInt)!=="function" '+typeof(parseInt)); From 663f6776aa799f7a9ef5e12eb36853c8f7186da3 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 7 Apr 2015 16:42:12 -0400 Subject: [PATCH 3/5] Add ES6 IDs --- test/language/expressions/typeof/boolean.js | 1 + test/language/expressions/typeof/built-in-functions.js | 1 + test/language/expressions/typeof/get-value.js | 1 + test/language/expressions/typeof/native-call.js | 1 + test/language/expressions/typeof/native-no-call.js | 1 + test/language/expressions/typeof/null.js | 1 + test/language/expressions/typeof/number.js | 1 + test/language/expressions/typeof/string.js | 1 + test/language/expressions/typeof/syntax.js | 1 + test/language/expressions/typeof/undefined.js | 1 + test/language/expressions/typeof/unresolvable-reference.js | 1 + 11 files changed, 11 insertions(+) diff --git a/test/language/expressions/typeof/boolean.js b/test/language/expressions/typeof/boolean.js index fa6970ae71..186c9281d9 100644 --- a/test/language/expressions/typeof/boolean.js +++ b/test/language/expressions/typeof/boolean.js @@ -4,6 +4,7 @@ /*--- info: Result of applying "typeof" operator to boolean is "boolean" es5id: 11.4.3_A3.3 +es6id: 12.5.6.1 description: typeof (boolean value) === "boolean" ---*/ diff --git a/test/language/expressions/typeof/built-in-functions.js b/test/language/expressions/typeof/built-in-functions.js index 83ed31e636..daf2cf8ede 100644 --- a/test/language/expressions/typeof/built-in-functions.js +++ b/test/language/expressions/typeof/built-in-functions.js @@ -6,6 +6,7 @@ info: > There are two types of Function objects. Internal functions are built-in objects of the language, such as parseInt and Math.exp es5id: 10.1.1_A2_T1 +es6id: 12.5.6.1 description: Checking types of parseInt and Math.exp ---*/ diff --git a/test/language/expressions/typeof/get-value.js b/test/language/expressions/typeof/get-value.js index df5ed3bf32..799c24950c 100644 --- a/test/language/expressions/typeof/get-value.js +++ b/test/language/expressions/typeof/get-value.js @@ -4,6 +4,7 @@ /*--- info: Operator "typeof" uses GetValue es5id: 11.4.3_A2_T1 +es6id: 12.5.6.1 description: Either Type(x) is not Reference or GetBase(x) is not null ---*/ diff --git a/test/language/expressions/typeof/native-call.js b/test/language/expressions/typeof/native-call.js index de81dc941a..2995594ab2 100644 --- a/test/language/expressions/typeof/native-call.js +++ b/test/language/expressions/typeof/native-call.js @@ -6,6 +6,7 @@ info: > Result of applying "typeof" operator to the object that is native and implements [[Call]] is "function" es5id: 11.4.3_A3.7 +es6id: 12.5.6.1 description: typeof (object with [[Call]]) === "function" ---*/ diff --git a/test/language/expressions/typeof/native-no-call.js b/test/language/expressions/typeof/native-no-call.js index 5d209b9391..93eb9bb9ba 100644 --- a/test/language/expressions/typeof/native-no-call.js +++ b/test/language/expressions/typeof/native-no-call.js @@ -6,6 +6,7 @@ info: > Result of applying "typeof" operator to the object that is native and doesn't implement [[Call]] is "object" es5id: 11.4.3_A3.6 +es6id: 12.5.6.1 description: typeof (object without [[Call]]) === "object" ---*/ diff --git a/test/language/expressions/typeof/null.js b/test/language/expressions/typeof/null.js index d38d1dfbea..97756626d8 100644 --- a/test/language/expressions/typeof/null.js +++ b/test/language/expressions/typeof/null.js @@ -4,6 +4,7 @@ /*--- info: Result of applying "typeof" operator to null is "object" es5id: 11.4.3_A3.2 +es6id: 12.5.6.1 description: typeof null === "object" ---*/ diff --git a/test/language/expressions/typeof/number.js b/test/language/expressions/typeof/number.js index d039646a70..c03d1ca07a 100644 --- a/test/language/expressions/typeof/number.js +++ b/test/language/expressions/typeof/number.js @@ -4,6 +4,7 @@ /*--- info: Result of appying "typeof" operator to number is "number" es5id: 11.4.3_A3.4 +es6id: 12.5.6.1 description: typeof (number value) === "number" ---*/ diff --git a/test/language/expressions/typeof/string.js b/test/language/expressions/typeof/string.js index ac9b23bebb..ee5b74d677 100644 --- a/test/language/expressions/typeof/string.js +++ b/test/language/expressions/typeof/string.js @@ -4,6 +4,7 @@ /*--- info: Result of appying "typeof" operator to string is "string" es5id: 11.4.3_A3.5 +es6id: 12.5.6.1 description: typeof (string value) === "string" ---*/ diff --git a/test/language/expressions/typeof/syntax.js b/test/language/expressions/typeof/syntax.js index 526d97b129..34c467ecca 100644 --- a/test/language/expressions/typeof/syntax.js +++ b/test/language/expressions/typeof/syntax.js @@ -6,6 +6,7 @@ info: > White Space and Line Terminator between "typeof" and UnaryExpression are allowed es5id: 11.4.3_A1 +es6id: 12.5.6.1 description: Checking by using eval ---*/ diff --git a/test/language/expressions/typeof/undefined.js b/test/language/expressions/typeof/undefined.js index 92e556f076..19afa7cd65 100644 --- a/test/language/expressions/typeof/undefined.js +++ b/test/language/expressions/typeof/undefined.js @@ -4,6 +4,7 @@ /*--- info: Result of applying "typeof" operator to undefined is "undefined" es5id: 11.4.3_A3.1 +es6id: 12.5.6.1 description: typeof undefined === "undefined" ---*/ diff --git a/test/language/expressions/typeof/unresolvable-reference.js b/test/language/expressions/typeof/unresolvable-reference.js index 8538132646..f70579cb1d 100644 --- a/test/language/expressions/typeof/unresolvable-reference.js +++ b/test/language/expressions/typeof/unresolvable-reference.js @@ -4,6 +4,7 @@ /*--- info: Operator "typeof" uses GetValue es5id: 11.4.3_A2_T2 +es6id: 12.5.6.1 description: If GetBase(x) is null, return "undefined" ---*/ From 3dce857e327d1f4f7f22737e206f355410776e70 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 7 Apr 2015 17:05:55 -0400 Subject: [PATCH 4/5] Update tests to use assertion library --- test/language/expressions/typeof/boolean.js | 27 +++-- .../expressions/typeof/built-in-functions.js | 16 ++- test/language/expressions/typeof/get-value.js | 27 +++-- .../expressions/typeof/native-call.js | 81 +++++++------ .../expressions/typeof/native-no-call.js | 108 ++++++++++-------- test/language/expressions/typeof/null.js | 18 +-- test/language/expressions/typeof/number.js | 45 ++++---- test/language/expressions/typeof/string.js | 54 +++++---- test/language/expressions/typeof/syntax.js | 90 ++++++++------- test/language/expressions/typeof/undefined.js | 18 +-- .../typeof/unresolvable-reference.js | 7 +- 11 files changed, 273 insertions(+), 218 deletions(-) diff --git a/test/language/expressions/typeof/boolean.js b/test/language/expressions/typeof/boolean.js index 186c9281d9..5e5f184b10 100644 --- a/test/language/expressions/typeof/boolean.js +++ b/test/language/expressions/typeof/boolean.js @@ -8,17 +8,20 @@ es6id: 12.5.6.1 description: typeof (boolean value) === "boolean" ---*/ -//CHECK#1 -if (typeof true !== "boolean") { - $ERROR('#1: typeof true === "boolean". Actual: ' + (typeof true)); -} +assert.sameValue( + typeof true, + "boolean", + '#1: typeof true === "boolean". Actual: ' + (typeof true) +); -//CHECK#2 -if (typeof false !== "boolean") { - $ERROR('#2: typeof false === "boolean". Actual: ' + (typeof false)); -} +assert.sameValue( + typeof false, + "boolean", + '#2: typeof false === "boolean". Actual: ' + (typeof false) +); -//CHECK#3 -if (typeof !-1 !== "boolean") { - $ERROR('#3: typeof !-1 === "boolean". Actual: ' + (typeof !-1)); -} +assert.sameValue( + typeof !-1, + "boolean", + '#3: typeof !-1 === "boolean". Actual: ' + (typeof !-1) +); diff --git a/test/language/expressions/typeof/built-in-functions.js b/test/language/expressions/typeof/built-in-functions.js index daf2cf8ede..08b86417fd 100644 --- a/test/language/expressions/typeof/built-in-functions.js +++ b/test/language/expressions/typeof/built-in-functions.js @@ -10,10 +10,14 @@ es6id: 12.5.6.1 description: Checking types of parseInt and Math.exp ---*/ -//CHECK#1 -if(typeof(Math.exp)!=="function") - $ERROR('#1: typeof(Math.exp)!=="function" '+typeof(Math.exp)); +assert.sameValue( + typeof(Math.exp), + "function", + '#1: typeof(Math.exp)!=="function" '+typeof(Math.exp) +); -//CHECK#2 -if(typeof(parseInt)!=="function") - $ERROR('#2: typeof(parseInt)!=="function" '+typeof(parseInt)); +assert.sameValue( + typeof(parseInt), + "function", + '#2: typeof(parseInt)!=="function" '+typeof(parseInt) +); diff --git a/test/language/expressions/typeof/get-value.js b/test/language/expressions/typeof/get-value.js index 799c24950c..2e52c0caa1 100644 --- a/test/language/expressions/typeof/get-value.js +++ b/test/language/expressions/typeof/get-value.js @@ -8,19 +8,22 @@ es6id: 12.5.6.1 description: Either Type(x) is not Reference or GetBase(x) is not null ---*/ -//CHECK#1 -if (typeof 0 !== "number") { - $ERROR('#1: typeof 0 === "number". Actual: ' + (typeof 0)); -} +assert.sameValue( + typeof 0, + "number", + '#1: typeof 0 === "number". Actual: ' + (typeof 0) +); -//CHECK#2 var x = 0; -if (typeof x !== "number") { - $ERROR('#2: typeof x === "number". Actual: ' + (typeof x)); -} +assert.sameValue( + typeof x, + "number", + '#2: typeof x === "number". Actual: ' + (typeof x) +); -//CHECK#3 var x = new Object(); -if (typeof x !== "object") { - $ERROR('#3: var x = new Object(); typeof x === "object". Actual: ' + (typeof x)); -} +assert.sameValue( + typeof x, + "object", + '#3: var x = new Object(); typeof x === "object". Actual: ' + (typeof x) +); diff --git a/test/language/expressions/typeof/native-call.js b/test/language/expressions/typeof/native-call.js index 2995594ab2..a4508e8798 100644 --- a/test/language/expressions/typeof/native-call.js +++ b/test/language/expressions/typeof/native-call.js @@ -10,47 +10,56 @@ es6id: 12.5.6.1 description: typeof (object with [[Call]]) === "function" ---*/ -//CHECK#1 -if (typeof new Function() !== "function") { - $ERROR('#1: typeof new Function() === "function". Actual: ' + (typeof new Function())); -} +assert.sameValue( + typeof new Function(), + "function", + '#1: typeof new Function() === "function". Actual: ' + (typeof new Function()) +); -//CHECK#2 -if (typeof Function() !== "function") { - $ERROR('#2: typeof Function() === "function". Actual: ' + (typeof Function())); -} +assert.sameValue( + typeof Function(), + "function", + '#2: typeof Function() === "function". Actual: ' + (typeof Function()) +); -//CHECK#3 -if (typeof Object !== "function") { - $ERROR('#3: typeof Object === "function". Actual: ' + (typeof Object)); -} +assert.sameValue( + typeof Object, + "function", + '#3: typeof Object === "function". Actual: ' + (typeof Object) +); -//CHECK#4 -if (typeof String !== "function") { - $ERROR('#4: typeof String === "function". Actual: ' + (typeof String)); -} +assert.sameValue( + typeof String, + "function", + '#4: typeof String === "function". Actual: ' + (typeof String) +); -//CHECK5 -if (typeof Boolean !== "function") { - $ERROR('#5: typeof Boolean === "function". Actual: ' + (typeof Boolean)); -} +assert.sameValue( + typeof Boolean, + "function", + '#5: typeof Boolean === "function". Actual: ' + (typeof Boolean) +); -//CHECK#6 -if (typeof Number !== "function") { - $ERROR('#6: typeof Number === "function". Actual: ' + (typeof Number)); -} +assert.sameValue( + typeof Number, + "function", + '#6: typeof Number === "function". Actual: ' + (typeof Number) +); -//CHECK#7 -if (typeof Date !== "function") { - $ERROR('#7: typeof Date === "function". Actual: ' + (typeof Date)); -} +assert.sameValue( + typeof Date, + "function", + '#7: typeof Date === "function". Actual: ' + (typeof Date) +); -//CHECK#8 -if (typeof Error !== "function") { - $ERROR('#8: typeof Error === "function". Actual: ' + (typeof Error)); -} +assert.sameValue( + typeof Error, + "function", + '#8: typeof Error === "function". Actual: ' + (typeof Error) +); -//CHECK#9 -if (typeof RegExp !== "function") { - $ERROR('#9: typeof RegExp === "function". Actual: ' + (typeof RegExp)); -} +assert.sameValue( + typeof RegExp, + "function", + '#9: typeof RegExp === "function". Actual: ' + (typeof RegExp) +); diff --git a/test/language/expressions/typeof/native-no-call.js b/test/language/expressions/typeof/native-no-call.js index 93eb9bb9ba..54401573c3 100644 --- a/test/language/expressions/typeof/native-no-call.js +++ b/test/language/expressions/typeof/native-no-call.js @@ -10,65 +10,77 @@ es6id: 12.5.6.1 description: typeof (object without [[Call]]) === "object" ---*/ -//CHECK#1 -if (typeof this !== "object") { - $ERROR('#1: typeof this === "object". Actual: ' + (typeof this)); -} +assert.sameValue( + typeof this, + "object", + '#1: typeof this === "object". Actual: ' + (typeof this) +); -//CHECK#2 -if (typeof new Object() !== "object") { - $ERROR('#2: typeof new Object() === "object". Actual: ' + (typeof new Object())); -} +assert.sameValue( + typeof new Object(), + "object", + '#2: typeof new Object() === "object". Actual: ' + (typeof new Object()) +); -//CHECK#3 -if (typeof new Array(1,2,3) !== "object") { - $ERROR('#3: typeof new Array(1,2,3) === "object". Actual: ' + (typeof new Array(1,2,3))); -} +assert.sameValue( + typeof new Array(1,2,3), + "object", + '#3: typeof new Array(1,2,3) === "object". Actual: ' + (typeof new Array(1,2,3)) +); -//CHECK#4 -if (typeof Array(1,2,3) !== "object") { - $ERROR('#4: typeof Array(1,2,3) === "object". Actual: ' + (typeof Array(1,2,3))); -} +assert.sameValue( + typeof Array(1,2,3), + "object", + '#4: typeof Array(1,2,3) === "object". Actual: ' + (typeof Array(1,2,3)) +); -//CHECK#5 -if (typeof new String("x") !== "object") { - $ERROR('#5: typeof new String("x") === "object". Actual: ' + (typeof new String("x"))); -} +assert.sameValue( + typeof new String("x"), + "object", + '#5: typeof new String("x") === "object". Actual: ' + (typeof new String("x")) +); -//CHECK#6 -if (typeof new Boolean(true) !== "object") { - $ERROR('#6: typeof new Boolean(true) === "object". Actual: ' + (typeof new Boolean(true))); -} +assert.sameValue( + typeof new Boolean(true), + "object", + '#6: typeof new Boolean(true) === "object". Actual: ' + (typeof new Boolean(true)) +); -//CHECK#7 -if (typeof new Number(1) !== "object") { - $ERROR('#7: typeof new Number(1) === "object". Actual: ' + (typeof new Number(1))); -} +assert.sameValue( + typeof new Number(1), + "object", + '#7: typeof new Number(1) === "object". Actual: ' + (typeof new Number(1)) +); -//CHECK#8 //The Math object does not have a [[Construct]] property; //it is not possible to use the Math object as a constructor with the new operator. //The Math object does not have a [[Call]] property; it is not possible to invoke the Math object as a object. -if (typeof Math !== "object") { - $ERROR('#8: typeof Math === "object". Actual: ' + (typeof Math)); -} +assert.sameValue( + typeof Math, + "object", + '#8: typeof Math === "object". Actual: ' + (typeof Math) +); -//CHECK#9 -if (typeof new Date() !== "object") { - $ERROR('#9: typeof new Date() === "object". Actual: ' + (typeof new Date())); -} +assert.sameValue( + typeof new Date(), + "object", + '#9: typeof new Date() === "object". Actual: ' + (typeof new Date()) +); -//CHECK#10 -if (typeof new Error() !== "object") { - $ERROR('#10: typeof new Error() === "object". Actual: ' + (typeof new Error())); -} +assert.sameValue( + typeof new Error(), + "object", + '#10: typeof new Error() === "object". Actual: ' + (typeof new Error()) +); -//CHECK#11 -if (typeof new RegExp() !== "object") { - $ERROR('#11: typeof new RegExp() === "object". Actual: ' + (typeof new RegExp())); -} +assert.sameValue( + typeof new RegExp(), + "object", + '#11: typeof new RegExp() === "object". Actual: ' + (typeof new RegExp()) +); -//CHECK#12 -if (typeof RegExp() !== "object") { - $ERROR('#12: typeof RegExp() === "object". Actual: ' + (typeof RegExp())); -} +assert.sameValue( + typeof RegExp(), + "object", + '#12: typeof RegExp() === "object". Actual: ' + (typeof RegExp()) +); diff --git a/test/language/expressions/typeof/null.js b/test/language/expressions/typeof/null.js index 97756626d8..9f81ea1470 100644 --- a/test/language/expressions/typeof/null.js +++ b/test/language/expressions/typeof/null.js @@ -8,12 +8,14 @@ es6id: 12.5.6.1 description: typeof null === "object" ---*/ -//CHECK#1 -if (typeof null !== "object") { - $ERROR('#1: typeof null === "object". Actual: ' + (typeof null)); -} +assert.sameValue( + typeof null, + "object", + '#1: typeof null === "object". Actual: ' + (typeof null) +); -//CHECK#2 -if (typeof RegExp("0").exec("1") !== "object") { - $ERROR('#2: typeof RegExp("0").exec("1") === "object". Actual: ' + (typeof RegExp("0").exec("1"))); -} +assert.sameValue( + typeof RegExp("0").exec("1"), + "object", + '#2: typeof RegExp("0").exec("1") === "object". Actual: ' + (typeof RegExp("0").exec("1")) +); diff --git a/test/language/expressions/typeof/number.js b/test/language/expressions/typeof/number.js index c03d1ca07a..2fb223971f 100644 --- a/test/language/expressions/typeof/number.js +++ b/test/language/expressions/typeof/number.js @@ -8,27 +8,32 @@ es6id: 12.5.6.1 description: typeof (number value) === "number" ---*/ -//CHECK#1 -if (typeof 1 !== "number") { - $ERROR('#1: typeof 1 === "number". Actual: ' + (typeof 1)); -} +assert.sameValue( + typeof 1, + "number", + '#1: typeof 1 === "number". Actual: ' + (typeof 1) +); -//CHECK#2 -if (typeof Number.NaN !== "number") { - $ERROR('#2: typeof NaN === "number". Actual: ' + (typeof NaN)); -} +assert.sameValue( + typeof Number.NaN, + "number", + '#2: typeof NaN === "number". Actual: ' + (typeof NaN) +); -//CHECK#3 -if (typeof Number.POSITIVE_INFINITY !== "number") { - $ERROR('#3: typeof Infinity === "number". Actual: ' + (typeof Infinity)); -} +assert.sameValue( + typeof Number.POSITIVE_INFINITY, + "number", + '#3: typeof Infinity === "number". Actual: ' + (typeof Infinity) +); -//CHECK#4 -if (typeof Number.NEGATIVE_INFINITY !== "number") { - $ERROR('#4: typeof -Infinity === "number". Actual: ' + (typeof -Infinity)); -} +assert.sameValue( + typeof Number.NEGATIVE_INFINITY, + "number", + '#4: typeof -Infinity === "number". Actual: ' + (typeof -Infinity) +); -//CHECK#5 -if (typeof Math.PI !== "number") { - $ERROR('#5: typeof Math.PI === "number". Actual: ' + (typeof Math.PI)); -} +assert.sameValue( + typeof Math.PI, + "number", + '#5: typeof Math.PI === "number". Actual: ' + (typeof Math.PI) +); diff --git a/test/language/expressions/typeof/string.js b/test/language/expressions/typeof/string.js index ee5b74d677..c5c5fbd045 100644 --- a/test/language/expressions/typeof/string.js +++ b/test/language/expressions/typeof/string.js @@ -8,32 +8,38 @@ es6id: 12.5.6.1 description: typeof (string value) === "string" ---*/ -//CHECK#1 -if (typeof "1" !== "string") { - $ERROR('#1: typeof "1" === "string". Actual: ' + (typeof "1")); -} +assert.sameValue( + typeof "1", + "string", + '#1: typeof "1" === "string". Actual: ' + (typeof "1") +); -//CHECK#2 -if (typeof "NaN" !== "string") { - $ERROR('#2: typeof "NaN" === "string". Actual: ' + (typeof "NaN")); -} +assert.sameValue( + typeof "NaN", + "string", + '#2: typeof "NaN" === "string". Actual: ' + (typeof "NaN") +); -//CHECK#3 -if (typeof "Infinity" !== "string") { - $ERROR('#3: typeof "Infinity" === "string". Actual: ' + (typeof "Infinity")); -} +assert.sameValue( + typeof "Infinity", + "string", + '#3: typeof "Infinity" === "string". Actual: ' + (typeof "Infinity") +); -//CHECK#4 -if (typeof "" !== "string") { - $ERROR('#4: typeof "" === "string". Actual: ' + (typeof "")); -} +assert.sameValue( + typeof "", + "string", + '#4: typeof "" === "string". Actual: ' + (typeof "") +); -//CHECK#5 -if (typeof "true" !== "string") { - $ERROR('#5: typeof "true" === "string". Actual: ' + (typeof "true")); -} +assert.sameValue( + typeof "true", + "string", + '#5: typeof "true" === "string". Actual: ' + (typeof "true") +); -//CHECK#6 -if (typeof Date() !== "string") { - $ERROR('#6: typeof Date() === "string". Actual: ' + (typeof Date())); -} +assert.sameValue( + typeof Date(), + "string", + '#6: typeof Date() === "string". Actual: ' + (typeof Date()) +); diff --git a/test/language/expressions/typeof/syntax.js b/test/language/expressions/typeof/syntax.js index 34c467ecca..63a9f0ec29 100644 --- a/test/language/expressions/typeof/syntax.js +++ b/test/language/expressions/typeof/syntax.js @@ -10,52 +10,62 @@ es6id: 12.5.6.1 description: Checking by using eval ---*/ -//CHECK#1 -if (eval("var x = 0; typeof\u0009x") !== "number") { - $ERROR('#1: var x = 0; typeof\\u0009x; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u0009x"), + "number", + '#1: var x = 0; typeof\\u0009x; x === "number". Actual: ' + (x) +); -//CHECK#2 -if (eval("var x = 0; typeof\u000Bx") !== "number") { - $ERROR('#2: var x = 0; typeof\\u000Bx; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u000Bx"), + "number", + '#2: var x = 0; typeof\\u000Bx; x === "number". Actual: ' + (x) +); -//CHECK#3 -if (eval("var x = 0; typeof\u000Cx") !== "number") { - $ERROR('#3: var x = 0; typeof\\u000Cx; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u000Cx"), + "number", + '#3: var x = 0; typeof\\u000Cx; x === "number". Actual: ' + (x) +); -//CHECK#4 -if (eval("var x = 0; typeof\u0020x") !== "number") { - $ERROR('#4: var x = 0; typeof\\u0020x; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u0020x"), + "number", + '#4: var x = 0; typeof\\u0020x; x === "number". Actual: ' + (x) +); -//CHECK#5 -if (eval("var x = 0; typeof\u00A0x") !== "number") { - $ERROR('#5: var x = 0; typeof\\u00A0x; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u00A0x"), + "number", + '#5: var x = 0; typeof\\u00A0x; x === "number". Actual: ' + (x) +); -//CHECK#6 -if (eval("var x = 0; typeof\u000Ax") !== "number") { - $ERROR('#6: var x = 0; typeof\\u000Ax; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u000Ax"), + "number", + '#6: var x = 0; typeof\\u000Ax; x === "number". Actual: ' + (x) +); -//CHECK#7 -if (eval("var x = 0; typeof\u000Dx") !== "number") { - $ERROR('#7: var x = 0; typeof\\u000Dx; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u000Dx"), + "number", + '#7: var x = 0; typeof\\u000Dx; x === "number". Actual: ' + (x) +); -//CHECK#8 -if (eval("var x = 0; typeof\u2028x") !== "number") { - $ERROR('#8: var x = 0; typeof\\u2028x; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u2028x"), + "number", + '#8: var x = 0; typeof\\u2028x; x === "number". Actual: ' + (x) +); -//CHECK#9 -if (eval("var x = 0; typeof\u2029x") !== "number") { - $ERROR('#9: var x = 0; typeof\\u2029x; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u2029x"), + "number", + '#9: var x = 0; typeof\\u2029x; x === "number". Actual: ' + (x) +); -//CHECK#10 -if (eval("var x = 0; typeof\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029x") !== "number") { - $ERROR('#10: var x = 0; typeof\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029x; x === "number". Actual: ' + (x)); -} +assert.sameValue( + eval("var x = 0; typeof\u0009\u000B\u000C\u0020\u00A0\u000A\u000D\u2028\u2029x"), + "number", + '#10: var x = 0; typeof\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029x; x === "number". Actual: ' + (x) +); diff --git a/test/language/expressions/typeof/undefined.js b/test/language/expressions/typeof/undefined.js index 19afa7cd65..77eaf78321 100644 --- a/test/language/expressions/typeof/undefined.js +++ b/test/language/expressions/typeof/undefined.js @@ -8,12 +8,14 @@ es6id: 12.5.6.1 description: typeof undefined === "undefined" ---*/ -//CHECK#1 -if (typeof undefined !== "undefined") { - $ERROR('#1: typeof undefined === "undefined". Actual: ' + (typeof undefined)); -} +assert.sameValue( + typeof undefined, + "undefined", + '#1: typeof undefined === "undefined". Actual: ' + (typeof undefined) +); -//CHECK#2 -if (typeof void 0 !== "undefined") { - $ERROR('#2: typeof void 0 === "undefined". Actual: ' + (typeof void 0)); -} +assert.sameValue( + typeof void 0, + "undefined", + '#2: typeof void 0 === "undefined". Actual: ' + (typeof void 0) +); diff --git a/test/language/expressions/typeof/unresolvable-reference.js b/test/language/expressions/typeof/unresolvable-reference.js index f70579cb1d..333cc9ac84 100644 --- a/test/language/expressions/typeof/unresolvable-reference.js +++ b/test/language/expressions/typeof/unresolvable-reference.js @@ -8,7 +8,6 @@ es6id: 12.5.6.1 description: If GetBase(x) is null, return "undefined" ---*/ -//CHECK#1 -if (typeof x !== "undefined") { - $ERROR('#1: typeof x === "undefined". Actual: ' + (typeof x)); -} +assert.sameValue( + typeof x, "undefined", '#1: typeof x === "undefined". Actual: ' + (typeof x) +); From 29326da2a86703585607f7507256ab91f265932f Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 7 Apr 2015 17:34:19 -0400 Subject: [PATCH 5/5] Normalize application of `typeof` operator Consistently use the `typeof` operator without the grouping operator (and include one explicit test to ensure the validity of this pattern generally). --- test/language/expressions/typeof/built-in-functions.js | 8 ++++---- test/language/expressions/typeof/syntax.js | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/test/language/expressions/typeof/built-in-functions.js b/test/language/expressions/typeof/built-in-functions.js index 08b86417fd..2e0dcc2d6c 100644 --- a/test/language/expressions/typeof/built-in-functions.js +++ b/test/language/expressions/typeof/built-in-functions.js @@ -11,13 +11,13 @@ description: Checking types of parseInt and Math.exp ---*/ assert.sameValue( - typeof(Math.exp), + typeof Math.exp, "function", - '#1: typeof(Math.exp)!=="function" '+typeof(Math.exp) + '#1: typeof Math.exp!=="function" '+typeof Math.exp ); assert.sameValue( - typeof(parseInt), + typeof parseInt, "function", - '#2: typeof(parseInt)!=="function" '+typeof(parseInt) + '#2: typeof parseInt!=="function" '+typeof parseInt ); diff --git a/test/language/expressions/typeof/syntax.js b/test/language/expressions/typeof/syntax.js index 63a9f0ec29..7759998971 100644 --- a/test/language/expressions/typeof/syntax.js +++ b/test/language/expressions/typeof/syntax.js @@ -69,3 +69,9 @@ assert.sameValue( "number", '#10: var x = 0; typeof\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029x; x === "number". Actual: ' + (x) ); + +assert.sameValue( + eval("typeof(0)"), + "number", + 'applied with grouping operator enclosing operand' +);