Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: LayoutTests/fast/js/script-tests/reserved-words-as-property.js

Issue 339363002: Fix invalid syntax for JS setters in tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 description("Tests to ensure that we can use ES reserved words as property names ."); 1 description("Tests to ensure that we can use ES reserved words as property names .");
2 2
3 var reservedWords = ["true", "false", "null", "break", "case", "catch", "continu e", "debugger", "default", "delete", "do", "else", "finally", "for", 3 var reservedWords = ["true", "false", "null", "break", "case", "catch", "continu e", "debugger", "default", "delete", "do", "else", "finally", "for",
4 "function", "if", "in", "instanceof", "new", "return", "swi tch", "this", "throw", "try", "typeof", "var", "void", "while", "with", 4 "function", "if", "in", "instanceof", "new", "return", "swi tch", "this", "throw", "try", "typeof", "var", "void", "while", "with",
5 "class", "const", "enum", "export", "extends", "import", "s uper"]; 5 "class", "const", "enum", "export", "extends", "import", "s uper"];
6 6
7 var strictReservedWords = [ 7 var strictReservedWords = [
8 "implements", 8 "implements",
9 "let", 9 "let",
10 "private", 10 "private",
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 function testWord(word, strictPrefix, expectedResult) { 49 function testWord(word, strictPrefix, expectedResult) {
50 testWordEvalAndFunction(strictPrefix + "var " + word + "; true", expectedRes ult); 50 testWordEvalAndFunction(strictPrefix + "var " + word + "; true", expectedRes ult);
51 testWordEvalAndFunction(strictPrefix + "var " + word + " = 42; " + word + " === 42", expectedResult); 51 testWordEvalAndFunction(strictPrefix + "var " + word + " = 42; " + word + " === 42", expectedResult);
52 testWordEvalAndFunction(strictPrefix + "function g(" + word + "){ " + strict Prefix + " }; true", expectedResult); 52 testWordEvalAndFunction(strictPrefix + "function g(" + word + "){ " + strict Prefix + " }; true", expectedResult);
53 testWordEvalAndFunction(strictPrefix + "/" + word + "/.test(function g(" + w ord + "){ " + strictPrefix + " })", expectedResult); 53 testWordEvalAndFunction(strictPrefix + "/" + word + "/.test(function g(" + w ord + "){ " + strictPrefix + " })", expectedResult);
54 testWordEvalAndFunction(strictPrefix + "try{}catch(" + word + "){}; true", e xpectedResult); 54 testWordEvalAndFunction(strictPrefix + "try{}catch(" + word + "){}; true", e xpectedResult);
55 testWordEvalAndFunction(strictPrefix + "function " + word + "(){ " + strictP refix + " }; true", expectedResult); 55 testWordEvalAndFunction(strictPrefix + "function " + word + "(){ " + strictP refix + " }; true", expectedResult);
56 // These should be allowed for all words, even reserved ones. 56 // These should be allowed for all words, even reserved ones.
57 testWordEvalAndFunction(strictPrefix + "({ \"" + word + "\": 42 }." + word + " === 42)", false); 57 testWordEvalAndFunction(strictPrefix + "({ \"" + word + "\": 42 }." + word + " === 42)", false);
58 testWordEvalAndFunction(strictPrefix + "({ " + word + ": 42 }." + word + " = == 42)", false); 58 testWordEvalAndFunction(strictPrefix + "({ " + word + ": 42 }." + word + " = == 42)", false);
59 testWordEvalAndFunction(strictPrefix + "({ get " + word + "(){}, set " + wor d + "(){}, parsedOkay: 42 }.parsedOkay === 42)", false); 59 testWordEvalAndFunction(strictPrefix + "({ get " + word + "(){}, set " + wor d + "(_){}, parsedOkay: 42 }.parsedOkay === 42)", false);
60 } 60 }
61 61
62 function testWordStrictAndNonStrict(word, condition) { 62 function testWordStrictAndNonStrict(word, condition) {
63 testWord(word, '', condition == "keyword"); 63 testWord(word, '', condition == "keyword");
64 testWord(word, '"use strict";', condition != "identifier"); 64 testWord(word, '"use strict";', condition != "identifier");
65 } 65 }
66 66
67 for (var i = 0; i < reservedWords.length; i++) 67 for (var i = 0; i < reservedWords.length; i++)
68 testWordStrictAndNonStrict(reservedWords[i], "keyword"); 68 testWordStrictAndNonStrict(reservedWords[i], "keyword");
69 for (var i = 0; i < strictReservedWords.length; i++) 69 for (var i = 0; i < strictReservedWords.length; i++)
70 testWordStrictAndNonStrict(strictReservedWords[i], "strict"); 70 testWordStrictAndNonStrict(strictReservedWords[i], "strict");
71 for (var i = 0; i < unreservedWords.length; i++) 71 for (var i = 0; i < unreservedWords.length; i++)
72 testWordStrictAndNonStrict(unreservedWords[i], "identifier"); 72 testWordStrictAndNonStrict(unreservedWords[i], "identifier");
73 73
74 // test access via window. 74 // test access via window.
75 var yield = 42; 75 var yield = 42;
76 shouldBeTrue("window.yield === 42"); 76 shouldBeTrue("window.yield === 42");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698