use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testSetTestOnlyWithInvalidArg.
@Test
public void testSetTestOnlyWithInvalidArg() {
testError("goog.setTestOnly(0);", GatherModuleMetadata.INVALID_SET_TEST_ONLY);
ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.isTestOnly()).isFalse();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testGoogInOtherScriptGoogIsClosure.
@Test
public void testGoogInOtherScriptGoogIsClosure() {
testSame(srcs("/** @provideGoog */ var goog = {};", "goog.isArray(foo);"));
ModuleMetadata m = metadataMap().getModulesByPath().get("testcode1");
assertThat(m.usesClosure()).isTrue();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testLoadModule.
@Test
public void testLoadModule() {
testSame(lines(//
"goog.loadModule(function(exports) {", " goog.module('my.module');", " return exports;", "});"));
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("my.module");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("my.module");
assertThat(m.googNamespaces()).containsExactly("my.module");
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 testGoogModuleWithDefaultExport.
@Test
public void testGoogModuleWithDefaultExport() {
// exports = 0; on its own is CommonJS!
testSame("goog.module('my.module'); exports = 0;");
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("my.module");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("my.module");
assertThat(m.googNamespaces()).containsExactly("my.module");
assertThat(m.isGoogProvide()).isFalse();
assertThat(m.isGoogModule()).isTrue();
assertThat(m.isNonLegacyGoogModule()).isTrue();
assertThat(m.isLegacyGoogModule()).isFalse();
}
use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.
the class GatherModuleMetadataTest method testMultipleGoogModuleCallsInLoadModule.
@Test
public void testMultipleGoogModuleCallsInLoadModule() {
testSame(lines(// Technically an error but this pass shouldn't report it.
"goog.loadModule(function(exports) {", " goog.module('multiple.calls.c0');", " goog.module('multiple.calls.c1');", " return exports;", "});"));
assertThat(metadataMap().getModulesByGoogNamespace().keySet()).containsExactly("multiple.calls.c0", "multiple.calls.c1");
ModuleMetadata m = metadataMap().getModulesByGoogNamespace().get("multiple.calls.c0");
assertThat(m.googNamespaces()).containsExactly("multiple.calls.c0", "multiple.calls.c1");
assertThat(metadataMap().getModulesByGoogNamespace().get("multiple.calls.c1")).isSameInstanceAs(m);
assertThat(m.isNonLegacyGoogModule()).isTrue();
assertThat(m.path()).isNull();
m = metadataMap().getModulesByPath().get("testcode");
assertThat(m.googNamespaces()).isEmpty();
assertThat(m.isNonProvideScript()).isTrue();
}
Aggregations