mirror of https://github.com/tc39/test262.git
97 lines
6.8 KiB
JSON
97 lines
6.8 KiB
JSON
{
|
|
"testCollection": {
|
|
"name": "7.4_Comments",
|
|
"numTests": 14,
|
|
"tests": [
|
|
{
|
|
"section": "7.4",
|
|
"description": "Create comments with any code",
|
|
"test": "//CHECK#1\n// $ERROR('#1: Correct interpretation single line comments');\n\n//CHECK#2\nvar x = 0;\n// x = 1;\nif (x !== 0) {\n $ERROR('#2: var x = 0; // x = 1; x === 0. Actual: ' + (x));\n}\n\n//CHECK#3\nvar // y = 1; \ny;\nif (y !== undefined) {\n $ERROR('#3: var // y = 1; \\\\n y; y === undefined. Actual: ' + (y));\n} \n\n//CHECK#4\n//$ERROR('#4: Correct interpretation single line comments') //$ERROR('#4: Correct interpretation single line comments'); //\n\n////CHECK#5\n//var x = 1;\n//if (x === 1) {\n// $ERROR('#5: Correct interpretation single line comments');\n//}\n\n//CHECK#6\n//var this.y = 1; \nthis.y++;\nif (isNaN(y) !== true) {\n $ERROR('#6: //var this.y = 1; \\\\n this.y++; y === Not-a-Number. Actual: ' + (y));\n}\n\n",
|
|
"id": "S7.4_A1_T1"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Simple test, create empty comment: ///",
|
|
"test": "//CHECK#1\n///\n",
|
|
"id": "S7.4_A1_T2"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Create comments with any code",
|
|
"test": "/*CHECK#1*/\n/* $ERROR('#1: Correct interpretation multi line comments');\n*/\n\n/*CHECK#2*/\nvar x = 0;\n/* x = 1;*/\nif (x !== 0) {\n $ERROR('#2: var x = 0; /* x = 1;*/ x === 0. Actual: ' + (x));\n}\n\n//CHECK#3\nvar /* y = 1;*/ \ny;\nif (y !== undefined) {\n $ERROR('#3: var /* y = 1; */ \\\\n y; y === undefined. Actual: ' + (y));\n} \n\n//CHECK#4\nvar /* y = 1;*/ y;\nif (y !== undefined) {\n $ERROR('#4: var /* y = 1; */ y; y === undefined. Actual: ' + (y));\n} \n\n/*CHECK#5*/\n/*var x = 1;\nif (x === 1) {\n $ERROR('#5: Correct interpretation multi line comments');\n}\n*/\n\n/*CHECK#6*/\n/*var this.y = 1;*/ \nthis.y++;\nif (isNaN(y) !== true) {\n $ERROR('#6: /*var this.y = 1;*/ \\\\n this.y++; y === Not-a-Number. Actual: ' + (y));\n}\n\n//CHECK#7\nvar string = \"/*var y = 0*/\" /* y = 1;*/ \nif (string !== \"/*var y = 0*/\") {\n$ERROR('#7: var string = \"/*var y = 0*/\" /* y = 1;*/ string === \"//var y = 0\"');\n}\n\n//CHECK#8\nvar string = \"/*var y = 0\" /* y = 1;*/ \nif (string !== \"/*var y = 0\") {\n$ERROR('#8: var string = \"/*var y = 0\" /* y = 1;*/ string === \"//var y = 0\"');\n}\n\n/*CHECK#9*/\n/** $ERROR('#9: Correct interpretation multi line comments');\n*/\n\n/*CHECK#10*/\n/* $ERROR('#10: Correct interpretation multi line comments');\n**/\n\n/*CHECK#11*/\n/****** $ERROR('#11: Correct interpretation multi line comments');*********\n***********\n*\n\n\n**********\n**/\n\n",
|
|
"id": "S7.4_A2_T1"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Try use /*CHECK#1/. This is not closed multi line comment",
|
|
"negative": "",
|
|
"test": "/*CHECK#1/\n",
|
|
"id": "S7.4_A2_T2"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Try use nested comments",
|
|
"negative": "",
|
|
"test": "/*CHECK#1*/\n\n/* \nvar\n\n/* x */\n= 1;\n*/\n",
|
|
"id": "S7.4_A3"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Try use 2 close comment tags",
|
|
"negative": "",
|
|
"test": "/*CHECK#1*/\n\n/* var*/\nx*/\n",
|
|
"id": "S7.4_A4_T1"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Fist Multi line comment, then Single line comment",
|
|
"test": "/*CHECK#1*/\n\n/* var\n*///x*/\n",
|
|
"id": "S7.4_A4_T2"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Insert Single line comment into Multi line comment",
|
|
"test": "/*CHECK#1*/\n\n/* var\n//x\n*/\n",
|
|
"id": "S7.4_A4_T3"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Try to open Multi line comment at the end of Single comment",
|
|
"negative": "",
|
|
"test": "/*CHECK#1*/\n\n// var /* \nx*/\n",
|
|
"id": "S7.4_A4_T4"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Insert Multi line comment into Single line comment",
|
|
"test": "/*CHECK#1*/\n\n// var /* x */\n",
|
|
"id": "S7.4_A4_T5"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Insert Multi line comment with two closed tags into Single line comment",
|
|
"test": "/*CHECK#1*/\n\n// var /* x / = */ 1 */\n",
|
|
"id": "S7.4_A4_T6"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "Insert Multi line comment into Single line comments",
|
|
"test": "/*CHECK#1*/\n\n// var /* \n// x \n// =\n// 1*/\n",
|
|
"id": "S7.4_A4_T7"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "//var \" + xx + \"yy = -1\", insert instead of xx all Unicode characters",
|
|
"test": "//CHECK\nerrorCount = 0;\ncount = 0;\nvar hex = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\"];\nfor (i1 = 0; i1 < 16; i1++) {\n for (i2 = 0; i2 < 16; i2++) {\n for (i3 = 0; i3 < 16; i3++) {\n for (i4 = 0; i4 < 16; i4++) {\n try { \n var uu = hex[i1] + hex[i2] + hex[i3] + hex[i4];\n var xx = String.fromCharCode(\"0x\" + uu);\n var LineTerminators = ((uu === \"000A\") || (uu === \"000D\") || (uu === \"2028\") || (uu === \"2029\"));\n var yy = 0; \n eval(\"//var \" + xx + \"yy = -1\"); \n if (LineTerminators !== true) { \n if (yy !== 0) {\n $ERROR('#' + uu + ' ');\n errorCount++;\n }\n } else {\n if (yy !== -1) {\n $ERROR('#' + uu + ' ');\n errorCount++;\n }\n }\n } catch (e){\n $ERROR('#' + uu + ' ');\n errorCount++;\n }\n count++;\n } \n }\n }\n}\n\nif (errorCount > 0) { \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count);\n}\n",
|
|
"id": "S7.4_A5"
|
|
},
|
|
{
|
|
"section": "7.4",
|
|
"description": "\"var\"+ yy+ \"xx = 1\", insert instead of yy all Unicode characters",
|
|
"test": "//CHECK\nerrorCount = 0;\ncount = 0;\nfor (indexI = 0; indexI <= 65535; indexI++) {\n try {\n var xx = 0; \n eval(\"/*var \" + String.fromCharCode(indexI) + \"xx = 1*/\");\n var hex = decimalToHexString(indexI);\n if (xx !== 0) {\n $ERROR('#' + hex + ' ');\n errorCount++;\n } \n } catch (e){\n $ERROR('#' + hex + ' ');\n errorCount++;\n }\n count++;\n} \n\nif (errorCount > 0) { \n $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count);\n}\n\nfunction decimalToHexString(n) {\n n = Number(n);\n var h = \"\";\n for (var i = 3; i >= 0; i--) {\n if (n >= Math.pow(16, i)) {\n var t = Math.floor(n / Math.pow(16, i));\n n -= t * Math.pow(16, i);\n if ( t >= 10 ) {\n if ( t == 10 ) { h += \"A\"; }\n if ( t == 11 ) { h += \"B\"; }\n if ( t == 12 ) { h += \"C\"; }\n if ( t == 13 ) { h += \"D\"; }\n if ( t == 14 ) { h += \"E\"; }\n if ( t == 15 ) { h += \"F\"; }\n } else {\n h += String(t);\n }\n } else {\n h += \"0\";\n }\n }\n return h;\n}\n",
|
|
"id": "S7.4_A6"
|
|
}
|
|
]
|
|
}
|
|
}
|