use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testGoogProvide.
@Test
public void testGoogProvide() {
testSame("goog.provide('my.provide');");
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("my.provide");
assertThat(metadataMap().getModulesByPath().keySet()).contains("testcode");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("my.provide");
assertThat(m.googNamespaces()).containsExactly("my.provide");
assertThat(m.isGoogProvide()).isTrue();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testMultipleGoogProvide.
@Test
public void testMultipleGoogProvide() {
testSame("goog.provide('my.first.provide'); goog.provide('my.second.provide');");
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("my.first.provide", "my.second.provide");
assertThat(metadataMap().getModulesByPath().keySet()).contains("testcode");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("my.first.provide");
assertThat(m.googNamespaces()).containsExactly("my.first.provide", "my.second.provide");
assertThat(m.isGoogProvide()).isTrue();
m = metadataMap().getModulesByGoogNamespace().get("my.second.provide");
assertThat(m.googNamespaces()).containsExactly("my.first.provide", "my.second.provide");
assertThat(m.isGoogProvide()).isTrue();
m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.googNamespaces()).containsExactly("my.first.provide", "my.second.provide");
assertThat(m.isGoogProvide()).isTrue();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testGatherFromExterns.
@Test
public void testGatherFromExterns() {
// js_lib will put data in externs for .i.js files.
test(externs("export var x; goog.declareModuleId('my.module');"), srcs(""));
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("my.module");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("my.module");
assertThat(m.googNamespaces()).containsExactly("my.module");
assertThat(m.isEs6Module()).isTrue();
assertThat(m.isGoogModule()).isFalse();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testLoadModuleLegacyNamespace.
@Test
public void testLoadModuleLegacyNamespace() {
testSame(lines(//
"goog.loadModule(function(exports) {", " goog.module('my.module');", " goog.module.declareLegacyNamespace();", " return exports;", "});"));
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("my.module");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("my.module");
assertThat(m.googNamespaces()).containsExactly("my.module");
assertThat(m.isLegacyGoogModule()).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 testUsesGlobalClosureNoFunctionCall.
@Test
public void testUsesGlobalClosureNoFunctionCall() {
testSame("var b = goog.nullFunction;");
ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.usesClosure()).isTrue();
}
Aggregations