use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GlobalNamespaceTest method googLoadModule_capturesQualifiedNames.
@Test
public void googLoadModule_capturesQualifiedNames() {
GlobalNamespace namespace = parseAndGatherModuleData(lines("goog.loadModule(function(exports) {", " goog.module('m');", " class Foo {}", " Foo.Bar = class {};", " return exports;", "});"));
ModuleMetadata metadata = lastCompiler.getModuleMetadataMap().getModulesByGoogNamespace().get("m");
Name foo = namespace.getNameFromModule(metadata, "Foo");
Name fooBar = namespace.getNameFromModule(metadata, "Foo.Bar");
assertThat(fooBar.getParent()).isEqualTo(foo);
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testRequireType.
@Test
public void testRequireType() {
testSame("goog.requireType('my.Type');");
ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.weaklyRequiredGoogNamespaces()).containsExactly("my.Type");
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testBundleGoogLoadModuleAndProvidesWithGoogDefined.
@Test
public void testBundleGoogLoadModuleAndProvidesWithGoogDefined() {
testSame(lines("/** @provideGoog */", "var goog = {};", "", "goog.provide('some.provide');", "", "goog.provide('some.other.provide');", "", "goog.loadModule(function(exports) {", " goog.module('multiple.calls.c0');", " return exports;", "});", "", "goog.loadModule(function(exports) {", " goog.module('multiple.calls.c1');", " return exports;", "});"));
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("some.provide", "some.other.provide", "multiple.calls.c0", "multiple.calls.c1");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("multiple.calls.c0");
assertThat(m.googNamespaces()).containsExactly("multiple.calls.c0");
assertThat(m.isNonLegacyGoogModule()).isTrue();
assertThat(m.path()).isNull();
assertThat(m.usesClosure()).isFalse();
m = metadataMap().getModulesByGoogNamespace().get("multiple.calls.c1");
assertThat(m.googNamespaces()).containsExactly("multiple.calls.c1");
assertThat(m.isNonLegacyGoogModule()).isTrue();
assertThat(m.path()).isNull();
assertThat(m.usesClosure()).isFalse();
m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.googNamespaces()).containsExactly("some.provide", "some.other.provide");
assertThat(m.isGoogProvide()).isTrue();
assertThat(m.usesClosure()).isFalse();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testLoadModuleUseStrict.
@Test
public void testLoadModuleUseStrict() {
testSame(lines(//
"goog.loadModule(function(exports) {", " 'use strict';", " goog.module('with.strict');", " return exports;", "});"));
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("with.strict");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("with.strict");
assertThat(m.googNamespaces()).containsExactly("with.strict");
assertThat(m.isNonLegacyGoogModule()).isTrue();
assertThat(m.path()).isNull();
m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.googNamespaces()).isEmpty();
assertThat(m.isNonProvideScript()).isTrue();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testSetTestOnly.
@Test
public void testSetTestOnly() {
testSame("goog.setTestOnly();");
ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.isTestOnly()).isTrue();
}
Aggregations