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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 1817353007: Fix "use types" directive in modules (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@types
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7494 matching lines...) Expand 10 before | Expand all | Expand 10 after
7505 RunParserSyncTest(typed_context_data, untyped_data, kSuccess, NULL, 0, 7505 RunParserSyncTest(typed_context_data, untyped_data, kSuccess, NULL, 0,
7506 always_flags, arraysize(always_flags)); 7506 always_flags, arraysize(always_flags));
7507 RunParserSyncTest(untyped_context_data, typed_data, kError, NULL, 0, 7507 RunParserSyncTest(untyped_context_data, typed_data, kError, NULL, 0,
7508 always_flags, arraysize(always_flags)); 7508 always_flags, arraysize(always_flags));
7509 RunParserSyncTest(typed_context_data, typed_data, kSuccess, NULL, 0, 7509 RunParserSyncTest(typed_context_data, typed_data, kSuccess, NULL, 0,
7510 always_flags, arraysize(always_flags)); 7510 always_flags, arraysize(always_flags));
7511 RunParserSyncTest(untyped_context_data, typed_error_data, kError, NULL, 0, 7511 RunParserSyncTest(untyped_context_data, typed_error_data, kError, NULL, 0,
7512 always_flags, arraysize(always_flags)); 7512 always_flags, arraysize(always_flags));
7513 RunParserSyncTest(typed_context_data, typed_error_data, kError, NULL, 0, 7513 RunParserSyncTest(typed_context_data, typed_error_data, kError, NULL, 0,
7514 always_flags, arraysize(always_flags)); 7514 always_flags, arraysize(always_flags));
7515 RunModuleParserSyncTest(untyped_context_data, untyped_data, kSuccess, NULL, 0,
7516 always_flags, arraysize(always_flags));
7517 RunModuleParserSyncTest(typed_context_data, untyped_data, kSuccess, NULL, 0,
7518 always_flags, arraysize(always_flags));
7519 RunModuleParserSyncTest(untyped_context_data, typed_data, kError, NULL, 0,
7520 always_flags, arraysize(always_flags));
7521 RunModuleParserSyncTest(typed_context_data, typed_data, kSuccess, NULL, 0,
7522 always_flags, arraysize(always_flags));
7523 RunModuleParserSyncTest(untyped_context_data, typed_error_data, kError, NULL,
7524 0, always_flags, arraysize(always_flags));
7525 RunModuleParserSyncTest(typed_context_data, typed_error_data, kError, NULL, 0,
7526 always_flags, arraysize(always_flags));
7515 } 7527 }
7516 7528
7517 TEST(TypedModeChecks) { 7529 TEST(TypedModeChecks) {
7518 const char* strict_context_data[][2] = { 7530 const char* strict_context_data[][2] = {
7519 {"'use types'; ", ""}, 7531 {"'use types'; ", ""},
7520 {"'use strict'; 'use types'; ", ""}, 7532 {"'use strict'; 'use types'; ", ""},
7521 {"'use types'; 'use strict'; ", ""}, 7533 {"'use types'; 'use strict'; ", ""},
7522 {"'use strict'; 'use types'; 'use strict'; ", ""}, 7534 {"'use strict'; 'use types'; 'use strict'; ", ""},
7523 {"'use types'; 'use strict'; 'use types'; ", ""}, 7535 {"'use types'; 'use strict'; 'use types'; ", ""},
7524 {NULL, NULL} 7536 {NULL, NULL}
7525 }; 7537 };
7526 7538
7527 const char* typed_data[] = { 7539 const char* typed_data[] = {
7528 "let x: number = 42", 7540 "let x: number = 42",
7529 "const s: string = 'hello world'", 7541 "const s: string = 'hello world'",
7530 NULL 7542 NULL
7531 }; 7543 };
7532 7544
7533 const char* strict_error_data[] = { 7545 const char* strict_error_data[] = {
7534 "var x = 42; delete x", 7546 "var x = 42; delete x",
7535 NULL 7547 NULL
7536 }; 7548 };
7537 7549
7538 static const ParserFlag always_flags[] = {kAllowTypes}; 7550 static const ParserFlag always_flags[] = {kAllowTypes};
7539 RunParserSyncTest(strict_context_data, typed_data, kSuccess, NULL, 0, 7551 RunParserSyncTest(strict_context_data, typed_data, kSuccess, NULL, 0,
7540 always_flags, arraysize(always_flags)); 7552 always_flags, arraysize(always_flags));
7541 RunParserSyncTest(strict_context_data, strict_error_data, kError, NULL, 0, 7553 RunParserSyncTest(strict_context_data, strict_error_data, kError, NULL, 0,
7542 always_flags, arraysize(always_flags)); 7554 always_flags, arraysize(always_flags));
7555 RunModuleParserSyncTest(strict_context_data, typed_data, kSuccess, NULL, 0,
7556 always_flags, arraysize(always_flags));
7557 RunModuleParserSyncTest(strict_context_data, strict_error_data, kError, NULL,
7558 0, always_flags, arraysize(always_flags));
7543 } 7559 }
7544 7560
7545 TEST(TypedModeIllegalInFunctionScope) { 7561 TEST(TypedModeIllegalInFunctionScope) {
7546 const char* context_data[][2] = { 7562 const char* context_data[][2] = {
7547 { "", "" }, 7563 { "", "" },
7548 { "'use types'; ", "" }, 7564 { "'use types'; ", "" },
7549 { NULL, NULL } 7565 { NULL, NULL }
7550 }; 7566 };
7551 7567
7552 const char* error_data[] = { 7568 const char* error_data[] = {
7553 "function f() { 'use types'; }", 7569 "function f() { 'use types'; }",
7554 "function f() { 'use types'; 'use strict'; }", 7570 "function f() { 'use types'; 'use strict'; }",
7555 "function f() { 'use strict'; 'use types'; }", 7571 "function f() { 'use strict'; 'use types'; }",
7556 NULL 7572 NULL
7557 }; 7573 };
7558 7574
7559 RunParserSyncTest(context_data, error_data, kSuccess); 7575 RunParserSyncTest(context_data, error_data, kSuccess);
7576 RunModuleParserSyncTest(context_data, error_data, kSuccess);
7560 7577
7561 static const ParserFlag typed_flags[] = {kAllowTypes}; 7578 static const ParserFlag typed_flags[] = {kAllowTypes};
7562 RunParserSyncTest(context_data, error_data, kError, NULL, 0, 7579 RunParserSyncTest(context_data, error_data, kError, NULL, 0,
7563 typed_flags, arraysize(typed_flags)); 7580 typed_flags, arraysize(typed_flags));
7581 RunModuleParserSyncTest(context_data, error_data, kError, NULL, 0,
7582 typed_flags, arraysize(typed_flags));
7564 } 7583 }
7565 7584
7566 TEST(TypedModeSimpleTypes) { 7585 TEST(TypedModeSimpleTypes) {
7567 const char* untyped_context_data[][2] = {{"", ""}, {NULL, NULL}}; 7586 const char* untyped_context_data[][2] = {{"", ""}, {NULL, NULL}};
7568 const char* typed_context_data[][2] = {{"'use types'; ", ""}, {NULL, NULL}}; 7587 const char* typed_context_data[][2] = {{"'use types'; ", ""}, {NULL, NULL}};
7569 7588
7570 const char* correct_data[] = { 7589 const char* correct_data[] = {
7571 "var x: number", 7590 "var x: number",
7572 "var x: (number)", 7591 "var x: (number)",
7573 "var x: ((number))", 7592 "var x: ((number))",
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
7811 static const ParserFlag always_flags[] = {kAllowTypes}; 7830 static const ParserFlag always_flags[] = {kAllowTypes};
7812 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0, 7831 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0,
7813 always_flags, arraysize(always_flags)); 7832 always_flags, arraysize(always_flags));
7814 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0, 7833 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0,
7815 always_flags, arraysize(always_flags)); 7834 always_flags, arraysize(always_flags));
7816 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0, 7835 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0,
7817 always_flags, arraysize(always_flags)); 7836 always_flags, arraysize(always_flags));
7818 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0, 7837 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0,
7819 always_flags, arraysize(always_flags)); 7838 always_flags, arraysize(always_flags));
7820 } 7839 }
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698