OLD | NEW |
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 3553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3564 CompileRun("\"use asm\";\n" | 3564 CompileRun("\"use asm\";\n" |
3565 "var foo = 1;\n" | 3565 "var foo = 1;\n" |
3566 "\"use asm\";\n" // Only the first one counts. | 3566 "\"use asm\";\n" // Only the first one counts. |
3567 "function bar() { \"use asm\"; var baz = 1; }"); | 3567 "function bar() { \"use asm\"; var baz = 1; }"); |
3568 // Optimizing will double-count because the source is parsed twice. | 3568 // Optimizing will double-count because the source is parsed twice. |
3569 CHECK_EQ(i::FLAG_always_opt ? 4 : 2, use_counts[v8::Isolate::kUseAsm]); | 3569 CHECK_EQ(i::FLAG_always_opt ? 4 : 2, use_counts[v8::Isolate::kUseAsm]); |
3570 } | 3570 } |
3571 | 3571 |
3572 | 3572 |
3573 TEST(UseConstLegacyCount) { | 3573 TEST(UseConstLegacyCount) { |
| 3574 i::FLAG_legacy_const = true; |
3574 i::Isolate* isolate = CcTest::i_isolate(); | 3575 i::Isolate* isolate = CcTest::i_isolate(); |
3575 i::HandleScope scope(isolate); | 3576 i::HandleScope scope(isolate); |
3576 LocalContext env; | 3577 LocalContext env; |
3577 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; | 3578 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {}; |
3578 global_use_counts = use_counts; | 3579 global_use_counts = use_counts; |
3579 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); | 3580 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); |
3580 CompileRun( | 3581 CompileRun( |
3581 "const x = 1;\n" | 3582 "const x = 1;\n" |
3582 "var foo = 1;\n" | 3583 "var foo = 1;\n" |
3583 "const y = 1;\n" | 3584 "const y = 1;\n" |
(...skipping 2834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6418 "((a)/*\n*/=> a)(1)", | 6419 "((a)/*\n*/=> a)(1)", |
6419 "((a, b)\n=> a + b)(1, 2)", | 6420 "((a, b)\n=> a + b)(1, 2)", |
6420 "((a, b)/*\n*/=> a + b)(1, 2)", | 6421 "((a, b)/*\n*/=> a + b)(1, 2)", |
6421 NULL}; | 6422 NULL}; |
6422 RunParserSyncTest(context_data, data, kError); | 6423 RunParserSyncTest(context_data, data, kError); |
6423 } | 6424 } |
6424 | 6425 |
6425 | 6426 |
6426 TEST(StrongModeFreeVariablesDeclaredByPreviousScript) { | 6427 TEST(StrongModeFreeVariablesDeclaredByPreviousScript) { |
6427 i::FLAG_strong_mode = true; | 6428 i::FLAG_strong_mode = true; |
| 6429 i::FLAG_legacy_const = true; |
6428 v8::V8::Initialize(); | 6430 v8::V8::Initialize(); |
6429 v8::HandleScope scope(CcTest::isolate()); | 6431 v8::HandleScope scope(CcTest::isolate()); |
6430 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate())); | 6432 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate())); |
6431 v8::TryCatch try_catch(CcTest::isolate()); | 6433 v8::TryCatch try_catch(CcTest::isolate()); |
6432 | 6434 |
6433 // Introduce a bunch of variables, in all language modes. | 6435 // Introduce a bunch of variables, in all language modes. |
6434 const char* script1 = | 6436 const char* script1 = |
6435 "var my_var1 = 0; \n" | 6437 "var my_var1 = 0; \n" |
6436 "function my_func1() { } \n" | 6438 "function my_func1() { } \n" |
6437 "const my_const1 = 0; \n"; | 6439 "const my_const1 = 0; \n"; |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7770 } | 7772 } |
7771 | 7773 |
7772 | 7774 |
7773 TEST(MiscSyntaxErrors) { | 7775 TEST(MiscSyntaxErrors) { |
7774 const char* context_data[][2] = { | 7776 const char* context_data[][2] = { |
7775 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; | 7777 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; |
7776 const char* error_data[] = {"for (();;) {}", NULL}; | 7778 const char* error_data[] = {"for (();;) {}", NULL}; |
7777 | 7779 |
7778 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); | 7780 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); |
7779 } | 7781 } |
OLD | NEW |