| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
| 8 | 8 |
| 9 using namespace v8::internal; | 9 using namespace v8::internal; |
| 10 using namespace v8::internal::compiler; | 10 using namespace v8::internal::compiler; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 static const char* bind_tests[] = { | 43 static const char* bind_tests[] = { |
| 44 "if (a) { const x = a }; r = x;", "123", "undefined", | 44 "if (a) { const x = a }; r = x;", "123", "undefined", |
| 45 "for (; a > 0; a--) { const x = a }; r = x", "123", "undefined", | 45 "for (; a > 0; a--) { const x = a }; r = x", "123", "undefined", |
| 46 // Re-initialization of variables other than legacy 'const' is not | 46 // Re-initialization of variables other than legacy 'const' is not |
| 47 // possible due to sane variable scoping, hence no tests here. | 47 // possible due to sane variable scoping, hence no tests here. |
| 48 NULL}; | 48 NULL}; |
| 49 | 49 |
| 50 | 50 |
| 51 static void RunVariableTests(const char* source, const char* tests[]) { | 51 static void RunVariableTests(const char* source, const char* tests[]) { |
| 52 FLAG_harmony_scoping = true; | |
| 53 EmbeddedVector<char, 512> buffer; | 52 EmbeddedVector<char, 512> buffer; |
| 54 | 53 |
| 55 for (int i = 0; tests[i] != NULL; i += 3) { | 54 for (int i = 0; tests[i] != NULL; i += 3) { |
| 56 SNPrintF(buffer, source, tests[i]); | 55 SNPrintF(buffer, source, tests[i]); |
| 57 PrintF("#%d: %s\n", i / 3, buffer.start()); | 56 PrintF("#%d: %s\n", i / 3, buffer.start()); |
| 58 FunctionTester T(buffer.start()); | 57 FunctionTester T(buffer.start()); |
| 59 | 58 |
| 60 // Check function with non-falsey parameter. | 59 // Check function with non-falsey parameter. |
| 61 if (tests[i + 1] != throws) { | 60 if (tests[i + 1] != throws) { |
| 62 Handle<Object> r = v8::Utils::OpenHandle(*CompileRun(tests[i + 1])); | 61 Handle<Object> r = v8::Utils::OpenHandle(*CompileRun(tests[i + 1])); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 111 } |
| 113 | 112 |
| 114 | 113 |
| 115 TEST(SelfReferenceVariable) { | 114 TEST(SelfReferenceVariable) { |
| 116 FunctionTester T("(function self() { return self; })"); | 115 FunctionTester T("(function self() { return self; })"); |
| 117 | 116 |
| 118 T.CheckCall(T.function); | 117 T.CheckCall(T.function); |
| 119 CompileRun("var self = 'not a function'"); | 118 CompileRun("var self = 'not a function'"); |
| 120 T.CheckCall(T.function); | 119 T.CheckCall(T.function); |
| 121 } | 120 } |
| OLD | NEW |