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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp

Issue 2788573002: [ES6 modules] Introduce ScriptModule::moduleRequests to access record.[[RequestedModules]] (Closed)
Patch Set: add_tests Created 3 years, 8 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium 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 "bindings/core/v8/ScriptModule.h" 5 #include "bindings/core/v8/ScriptModule.h"
6 6
7 #include "bindings/core/v8/V8BindingForTesting.h" 7 #include "bindings/core/v8/V8BindingForTesting.h"
8 #include "testing/gmock/include/gmock/gmock-matchers.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "v8/include/v8.h" 10 #include "v8/include/v8.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 namespace { 14 namespace {
14 15
15 TEST(ScriptModuleTest, compileSuccess) { 16 TEST(ScriptModuleTest, compileSuccess) {
16 V8TestingScope scope; 17 V8TestingScope scope;
17 ScriptModule module = 18 ScriptModule module =
18 ScriptModule::compile(scope.isolate(), "export const a = 42;", "foo.js"); 19 ScriptModule::compile(scope.isolate(), "export const a = 42;", "foo.js");
19 ASSERT_FALSE(module.isNull()); 20 ASSERT_FALSE(module.isNull());
20 } 21 }
21 22
22 TEST(ScriptModuleTest, compileFail) { 23 TEST(ScriptModuleTest, compileFail) {
23 V8TestingScope scope; 24 V8TestingScope scope;
24 ScriptModule module = 25 ScriptModule module =
25 ScriptModule::compile(scope.isolate(), "123 = 456", "foo.js"); 26 ScriptModule::compile(scope.isolate(), "123 = 456", "foo.js");
26 ASSERT_TRUE(module.isNull()); 27 ASSERT_TRUE(module.isNull());
27 } 28 }
28 29
30 TEST(ScriptModuleTest, moduleRequests) {
31 V8TestingScope scope;
32 ScriptModule module = ScriptModule::compile(
33 scope.isolate(), "import 'a'; import 'b'; export const c = 'c';",
34 "foo.js");
35 ASSERT_FALSE(module.isNull());
36
37 auto requests = module.moduleRequests(scope.getScriptState());
38 EXPECT_THAT(requests, ::testing::ContainerEq<Vector<String>>({"a", "b"}));
39 }
40
29 } // namespace 41 } // namespace
30 42
31 } // namespace blink 43 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698