Chromium Code Reviews| 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 23586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 23597 CHECK(script1->GetPositionInfo(9, &info, script1->NO_OFFSET)); | 23597 CHECK(script1->GetPositionInfo(9, &info, script1->NO_OFFSET)); |
| 23598 CHECK_EQ(1, info.line); | 23598 CHECK_EQ(1, info.line); |
| 23599 CHECK_EQ(0, info.column); | 23599 CHECK_EQ(0, info.column); |
| 23600 CHECK_EQ(9, info.line_start); | 23600 CHECK_EQ(9, info.line_start); |
| 23601 CHECK_EQ(17, info.line_end); | 23601 CHECK_EQ(17, info.line_end); |
| 23602 | 23602 |
| 23603 // Fail when position is larger than script size. | 23603 // Fail when position is larger than script size. |
| 23604 CHECK(!script1->GetPositionInfo(220384, &info, script1->NO_OFFSET)); | 23604 CHECK(!script1->GetPositionInfo(220384, &info, script1->NO_OFFSET)); |
| 23605 } | 23605 } |
| 23606 | 23606 |
| 23607 TEST(ScriptIsModule) { | |
| 23608 LocalContext env; | |
| 23609 v8::Isolate* isolate = env->GetIsolate(); | |
| 23610 v8::HandleScope scope(isolate); | |
| 23611 const char* url = "http://www.foo.com/foo.js"; | |
| 23612 v8::ScriptOrigin origin(v8_str(url), v8::Integer::New(isolate, 1)); | |
| 23613 Local<Script> localScript; | |
| 23614 i::Handle<i::SharedFunctionInfo> fnInfo; | |
| 23615 | |
| 23616 v8::ScriptCompiler::Source script_source1(v8_str("void 1;\n"), origin); | |
| 23617 localScript = v8::ScriptCompiler::Compile(env.local(), &script_source1) | |
| 23618 .ToLocalChecked(); | |
| 23619 fnInfo = i::Handle<i::SharedFunctionInfo>::cast( | |
| 23620 v8::Utils::OpenHandle(*localScript->GetUnboundScript())); | |
| 23621 i::Handle<i::Script> globalScript(i::Script::cast(fnInfo->script())); | |
| 23622 CHECK_EQ(false, globalScript->is_module()); | |
| 23623 | |
| 23624 v8::ScriptCompiler::Source script_source2(v8_str("void 2;\n"), origin); | |
|
mike3
2016/06/12 19:54:48
A distinct Source object for each test case is nec
vogelheim
2016/06/14 15:20:50
This is a good catch! I hadn't thought of that...
mike3
2016/06/19 16:59:00
Much as I enjoy seeing my commit count increase (p
| |
| 23625 localScript = v8::ScriptCompiler::CompileModule(env.local(), &script_source2) | |
| 23626 .ToLocalChecked(); | |
| 23627 fnInfo = i::Handle<i::SharedFunctionInfo>::cast( | |
| 23628 v8::Utils::OpenHandle(*localScript->GetUnboundScript())); | |
| 23629 i::Handle<i::Script> moduleScript(i::Script::cast(fnInfo->script())); | |
| 23630 CHECK_EQ(true, moduleScript->is_module()); | |
| 23631 } | |
| 23632 | |
| 23607 void CheckMagicComments(Local<Script> script, const char* expected_source_url, | 23633 void CheckMagicComments(Local<Script> script, const char* expected_source_url, |
| 23608 const char* expected_source_mapping_url) { | 23634 const char* expected_source_mapping_url) { |
| 23609 if (expected_source_url != NULL) { | 23635 if (expected_source_url != NULL) { |
| 23610 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL()); | 23636 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL()); |
| 23611 CHECK_EQ(0, strcmp(expected_source_url, *url)); | 23637 CHECK_EQ(0, strcmp(expected_source_url, *url)); |
| 23612 } else { | 23638 } else { |
| 23613 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined()); | 23639 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined()); |
| 23614 } | 23640 } |
| 23615 if (expected_source_mapping_url != NULL) { | 23641 if (expected_source_mapping_url != NULL) { |
| 23616 v8::String::Utf8Value url( | 23642 v8::String::Utf8Value url( |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 25340 } | 25366 } |
| 25341 | 25367 |
| 25342 TEST(PrivateForApiIsNumber) { | 25368 TEST(PrivateForApiIsNumber) { |
| 25343 LocalContext context; | 25369 LocalContext context; |
| 25344 v8::Isolate* isolate = CcTest::isolate(); | 25370 v8::Isolate* isolate = CcTest::isolate(); |
| 25345 v8::HandleScope scope(isolate); | 25371 v8::HandleScope scope(isolate); |
| 25346 | 25372 |
| 25347 // Shouldn't crash. | 25373 // Shouldn't crash. |
| 25348 v8::Private::ForApi(isolate, v8_str("42")); | 25374 v8::Private::ForApi(isolate, v8_str("42")); |
| 25349 } | 25375 } |
| OLD | NEW |