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