Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(927)

Side by Side Diff: test/cctest/test-api.cc

Issue 2065453002: [module] Track script "module code" status Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use idiomatic variable names Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23587 matching lines...) Expand 10 before | Expand all | Expand 10 after
23598 CHECK(script1->GetPositionInfo(9, &info, script1->NO_OFFSET)); 23598 CHECK(script1->GetPositionInfo(9, &info, script1->NO_OFFSET));
23599 CHECK_EQ(1, info.line); 23599 CHECK_EQ(1, info.line);
23600 CHECK_EQ(0, info.column); 23600 CHECK_EQ(0, info.column);
23601 CHECK_EQ(9, info.line_start); 23601 CHECK_EQ(9, info.line_start);
23602 CHECK_EQ(17, info.line_end); 23602 CHECK_EQ(17, info.line_end);
23603 23603
23604 // Fail when position is larger than script size. 23604 // Fail when position is larger than script size.
23605 CHECK(!script1->GetPositionInfo(220384, &info, script1->NO_OFFSET)); 23605 CHECK(!script1->GetPositionInfo(220384, &info, script1->NO_OFFSET));
23606 } 23606 }
23607 23607
23608 TEST(ScriptIsModule) {
23609 LocalContext env;
23610 v8::Isolate* isolate = env->GetIsolate();
23611 v8::HandleScope scope(isolate);
23612 const char* url = "http://www.foo.com/foo.js";
23613 v8::ScriptOrigin origin(v8_str(url), v8::Integer::New(isolate, 1));
23614 v8::ScriptCompiler::Source script_source(v8_str("void 0;\n"), origin);
23615 Local<Script> local_script;
23616 i::Handle<i::SharedFunctionInfo> fn_info;
23617
23618 local_script =
23619 v8::ScriptCompiler::Compile(env.local(), &script_source).ToLocalChecked();
23620 fn_info = i::Handle<i::SharedFunctionInfo>::cast(
23621 v8::Utils::OpenHandle(*local_script->GetUnboundScript()));
23622 i::Handle<i::Script> globalScript(i::Script::cast(fn_info->script()));
23623 CHECK_EQ(false, globalScript->is_module());
23624
23625 local_script = v8::ScriptCompiler::CompileModule(env.local(), &script_source)
23626 .ToLocalChecked();
23627 fn_info = i::Handle<i::SharedFunctionInfo>::cast(
23628 v8::Utils::OpenHandle(*local_script->GetUnboundScript()));
23629 i::Handle<i::Script> moduleScript(i::Script::cast(fn_info->script()));
23630 CHECK_EQ(true, moduleScript->is_module());
23631 }
23632
23608 void CheckMagicComments(Local<Script> script, const char* expected_source_url, 23633 void CheckMagicComments(Local<Script> script, const char* expected_source_url,
23609 const char* expected_source_mapping_url) { 23634 const char* expected_source_mapping_url) {
23610 if (expected_source_url != NULL) { 23635 if (expected_source_url != NULL) {
23611 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL()); 23636 v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL());
23612 CHECK_EQ(0, strcmp(expected_source_url, *url)); 23637 CHECK_EQ(0, strcmp(expected_source_url, *url));
23613 } else { 23638 } else {
23614 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined()); 23639 CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined());
23615 } 23640 }
23616 if (expected_source_mapping_url != NULL) { 23641 if (expected_source_mapping_url != NULL) {
23617 v8::String::Utf8Value url( 23642 v8::String::Utf8Value url(
(...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after
25370 CHECK(object->SetPrototype(context.local(), v8::Null(isolate)).IsNothing()); 25395 CHECK(object->SetPrototype(context.local(), v8::Null(isolate)).IsNothing());
25371 25396
25372 // The original prototype is still there 25397 // The original prototype is still there
25373 Local<Value> new_proto = 25398 Local<Value> new_proto =
25374 object->Get(context.local(), v8_str("__proto__")).ToLocalChecked(); 25399 object->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
25375 CHECK(new_proto->IsObject()); 25400 CHECK(new_proto->IsObject());
25376 CHECK(new_proto.As<v8::Object>() 25401 CHECK(new_proto.As<v8::Object>()
25377 ->Equals(context.local(), original_proto) 25402 ->Equals(context.local(), original_proto)
25378 .FromJust()); 25403 .FromJust());
25379 } 25404 }
OLDNEW
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698