| 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 "test/cctest/compiler/function-tester.h" | 5 #include "test/cctest/compiler/function-tester.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace compiler { | 9 namespace compiler { |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 static const char* bind_tests[] = { | 42 static const char* bind_tests[] = { |
| 43 "if (a) { const x = a }; r = x;", "123", "undefined", | 43 "if (a) { const x = a }; r = x;", "123", "undefined", |
| 44 "for (; a > 0; a--) { const x = a }; r = x", "123", "undefined", | 44 "for (; a > 0; a--) { const x = a }; r = x", "123", "undefined", |
| 45 // Re-initialization of variables other than legacy 'const' is not | 45 // Re-initialization of variables other than legacy 'const' is not |
| 46 // possible due to sane variable scoping, hence no tests here. | 46 // possible due to sane variable scoping, hence no tests here. |
| 47 NULL}; | 47 NULL}; |
| 48 | 48 |
| 49 | 49 |
| 50 static void RunVariableTests(const char* source, const char* tests[]) { | 50 static void RunVariableTests(const char* source, const char* tests[]) { |
| 51 i::FLAG_legacy_const = true; |
| 51 EmbeddedVector<char, 512> buffer; | 52 EmbeddedVector<char, 512> buffer; |
| 52 | 53 |
| 53 for (int i = 0; tests[i] != NULL; i += 3) { | 54 for (int i = 0; tests[i] != NULL; i += 3) { |
| 54 SNPrintF(buffer, source, tests[i]); | 55 SNPrintF(buffer, source, tests[i]); |
| 55 PrintF("#%d: %s\n", i / 3, buffer.start()); | 56 PrintF("#%d: %s\n", i / 3, buffer.start()); |
| 56 FunctionTester T(buffer.start()); | 57 FunctionTester T(buffer.start()); |
| 57 | 58 |
| 58 // Check function with non-falsey parameter. | 59 // Check function with non-falsey parameter. |
| 59 if (tests[i + 1] != throws) { | 60 if (tests[i + 1] != throws) { |
| 60 Handle<Object> r = v8::Utils::OpenHandle(*CompileRun(tests[i + 1])); | 61 Handle<Object> r = v8::Utils::OpenHandle(*CompileRun(tests[i + 1])); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 FunctionTester T("(function self() { return self; })"); | 115 FunctionTester T("(function self() { return self; })"); |
| 115 | 116 |
| 116 T.CheckCall(T.function); | 117 T.CheckCall(T.function); |
| 117 CompileRun("var self = 'not a function'"); | 118 CompileRun("var self = 'not a function'"); |
| 118 T.CheckCall(T.function); | 119 T.CheckCall(T.function); |
| 119 } | 120 } |
| 120 | 121 |
| 121 } // namespace compiler | 122 } // namespace compiler |
| 122 } // namespace internal | 123 } // namespace internal |
| 123 } // namespace v8 | 124 } // namespace v8 |
| OLD | NEW |