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 v8::ScriptCompiler::Source script_source(v8_str("void 0;\n"), origin); |
| 23614 Local<Script> localScript; |
| 23615 i::Handle<i::SharedFunctionInfo> fnInfo; |
| 23616 |
| 23617 localScript = |
| 23618 v8::ScriptCompiler::Compile(env.local(), &script_source).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 localScript = v8::ScriptCompiler::CompileModule(env.local(), &script_source) |
| 23625 .ToLocalChecked(); |
| 23626 fnInfo = i::Handle<i::SharedFunctionInfo>::cast( |
| 23627 v8::Utils::OpenHandle(*localScript->GetUnboundScript())); |
| 23628 i::Handle<i::Script> moduleScript(i::Script::cast(fnInfo->script())); |
| 23629 CHECK_EQ(true, moduleScript->is_module()); |
| 23630 } |
| 23631 |
23607 void CheckMagicComments(Local<Script> script, const char* expected_source_url, | 23632 void CheckMagicComments(Local<Script> script, const char* expected_source_url, |
23608 const char* expected_source_mapping_url) { | 23633 const char* expected_source_mapping_url) { |
23609 if (expected_source_url != NULL) { | 23634 if (expected_source_url != NULL) { |
23610 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL()); | 23635 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL()); |
23611 CHECK_EQ(0, strcmp(expected_source_url, *url)); | 23636 CHECK_EQ(0, strcmp(expected_source_url, *url)); |
23612 } else { | 23637 } else { |
23613 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined()); | 23638 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined()); |
23614 } | 23639 } |
23615 if (expected_source_mapping_url != NULL) { | 23640 if (expected_source_mapping_url != NULL) { |
23616 v8::String::Utf8Value url( | 23641 v8::String::Utf8Value url( |
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25340 } | 25365 } |
25341 | 25366 |
25342 TEST(PrivateForApiIsNumber) { | 25367 TEST(PrivateForApiIsNumber) { |
25343 LocalContext context; | 25368 LocalContext context; |
25344 v8::Isolate* isolate = CcTest::isolate(); | 25369 v8::Isolate* isolate = CcTest::isolate(); |
25345 v8::HandleScope scope(isolate); | 25370 v8::HandleScope scope(isolate); |
25346 | 25371 |
25347 // Shouldn't crash. | 25372 // Shouldn't crash. |
25348 v8::Private::ForApi(isolate, v8_str("42")); | 25373 v8::Private::ForApi(isolate, v8_str("42")); |
25349 } | 25374 } |
OLD | NEW |