| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 const char* data() const { return data_; } | 169 const char* data() const { return data_; } |
| 170 size_t length() const { return length_; } | 170 size_t length() const { return length_; } |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 const char* data_; | 173 const char* data_; |
| 174 size_t length_; | 174 size_t length_; |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 | 177 |
| 178 TEST(Preparsing) { | 178 TEST(Preparsing) { |
| 179 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 179 v8::HandleScope handles(v8::Isolate::GetCurrent()); |
| 180 v8::HandleScope handles(isolate); | 180 v8::Persistent<v8::Context> context = v8::Context::New(); |
| 181 v8::Local<v8::Context> context = v8::Context::New(isolate); | 181 v8::Context::Scope context_scope(v8::Isolate::GetCurrent(), context); |
| 182 v8::Context::Scope context_scope(context); | |
| 183 int marker; | 182 int marker; |
| 184 i::Isolate::Current()->stack_guard()->SetStackLimit( | 183 i::Isolate::Current()->stack_guard()->SetStackLimit( |
| 185 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | 184 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
| 186 | 185 |
| 187 // Source containing functions that might be lazily compiled and all types | 186 // Source containing functions that might be lazily compiled and all types |
| 188 // of symbols (string, propertyName, regexp). | 187 // of symbols (string, propertyName, regexp). |
| 189 const char* source = | 188 const char* source = |
| 190 "var x = 42;" | 189 "var x = 42;" |
| 191 "function foo(a) { return function nolazy(b) { return a + b; } }" | 190 "function foo(a) { return function nolazy(b) { return a + b; } }" |
| 192 "function bar(a) { if (a) return function lazy(b) { return b; } }" | 191 "function bar(a) { if (a) return function lazy(b) { return b; } }" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 int32_t c1 = uc16_stream.Advance(); | 535 int32_t c1 = uc16_stream.Advance(); |
| 537 int32_t c2 = string_stream.Advance(); | 536 int32_t c2 = string_stream.Advance(); |
| 538 int32_t c3 = utf8_stream.Advance(); | 537 int32_t c3 = utf8_stream.Advance(); |
| 539 CHECK_LT(c1, 0); | 538 CHECK_LT(c1, 0); |
| 540 CHECK_LT(c2, 0); | 539 CHECK_LT(c2, 0); |
| 541 CHECK_LT(c3, 0); | 540 CHECK_LT(c3, 0); |
| 542 } | 541 } |
| 543 | 542 |
| 544 | 543 |
| 545 TEST(CharacterStreams) { | 544 TEST(CharacterStreams) { |
| 546 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 545 v8::HandleScope handles(v8::Isolate::GetCurrent()); |
| 547 v8::HandleScope handles(isolate); | 546 v8::Persistent<v8::Context> context = v8::Context::New(); |
| 548 v8::Local<v8::Context> context = v8::Context::New(isolate); | 547 v8::Context::Scope context_scope(v8::Isolate::GetCurrent(), context); |
| 549 v8::Context::Scope context_scope(context); | |
| 550 | 548 |
| 551 TestCharacterStream("abc\0\n\r\x7f", 7); | 549 TestCharacterStream("abc\0\n\r\x7f", 7); |
| 552 static const unsigned kBigStringSize = 4096; | 550 static const unsigned kBigStringSize = 4096; |
| 553 char buffer[kBigStringSize + 1]; | 551 char buffer[kBigStringSize + 1]; |
| 554 for (unsigned i = 0; i < kBigStringSize; i++) { | 552 for (unsigned i = 0; i < kBigStringSize; i++) { |
| 555 buffer[i] = static_cast<char>(i & 0x7f); | 553 buffer[i] = static_cast<char>(i & 0x7f); |
| 556 } | 554 } |
| 557 TestCharacterStream(buffer, kBigStringSize); | 555 TestCharacterStream(buffer, kBigStringSize); |
| 558 | 556 |
| 559 TestCharacterStream(buffer, kBigStringSize, 576, 3298); | 557 TestCharacterStream(buffer, kBigStringSize, 576, 3298); |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 " b = function() { \n" | 1296 " b = function() { \n" |
| 1299 " 01; \n" | 1297 " 01; \n" |
| 1300 " }; \n" | 1298 " }; \n" |
| 1301 "}; \n"; | 1299 "}; \n"; |
| 1302 v8::Script::Compile(v8::String::New(script)); | 1300 v8::Script::Compile(v8::String::New(script)); |
| 1303 CHECK(try_catch.HasCaught()); | 1301 CHECK(try_catch.HasCaught()); |
| 1304 v8::String::Utf8Value exception(try_catch.Exception()); | 1302 v8::String::Utf8Value exception(try_catch.Exception()); |
| 1305 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", | 1303 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", |
| 1306 *exception); | 1304 *exception); |
| 1307 } | 1305 } |
| OLD | NEW |