Search in sources :

Example 11 with ModuleMetadata

use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.

the class GatherModuleMetadataTest method testMultipleGoogLoadModules.

@Test
public void testMultipleGoogLoadModules() {
    testSame(lines("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("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();
    m = metadataMap().getModulesByGoogNamespace().get("multiple.calls.c1");
    assertThat(m.googNamespaces()).containsExactly("multiple.calls.c1");
    assertThat(m.isNonLegacyGoogModule()).isTrue();
    assertThat(m.path()).isNull();
    m = metadataMap().getModulesByPath().get("testcode");
    assertThat(m.googNamespaces()).isEmpty();
    assertThat(m.isNonProvideScript()).isTrue();
}
Also used : ModuleMetadata(com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata) Test(org.junit.Test)

Example 12 with ModuleMetadata

use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.

the class GatherModuleMetadataTest method testSetTestOnlyWithExtraArg.

@Test
public void testSetTestOnlyWithExtraArg() {
    testError("goog.setTestOnly('string', 'string');", GatherModuleMetadata.INVALID_SET_TEST_ONLY);
    ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
    assertThat(m.isTestOnly()).isFalse();
}
Also used : ModuleMetadata(com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata) Test(org.junit.Test)

Example 13 with ModuleMetadata

use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.

the class GatherModuleMetadataTest method testEs6Module.

@Test
public void testEs6Module() {
    testSame("export var x;");
    assertThat(metadataMap().getModulesByGoogNamespace().keySet()).isEmpty();
    assertThat(metadataMap().getModulesByPath().keySet()).contains("testcode");
    ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
    assertThat(m.googNamespaces()).isEmpty();
    assertThat(m.isEs6Module()).isTrue();
}
Also used : ModuleMetadata(com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata) Test(org.junit.Test)

Example 14 with ModuleMetadata

use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.

the class GatherModuleMetadataTest method testUsesGlobalClosure.

@Test
public void testUsesGlobalClosure() {
    testSame("goog.isArray(foo);");
    ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
    assertThat(m.usesClosure()).isTrue();
}
Also used : ModuleMetadata(com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata) Test(org.junit.Test)

Example 15 with ModuleMetadata

use of com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata in project closure-compiler by google.

the class GatherModuleMetadataTest method testCommonJsModule.

@Test
public void testCommonJsModule() {
    testSame("exports = 0;");
    assertThat(metadataMap().getModulesByGoogNamespace()).isEmpty();
    ModuleMetadata m = metadataMap().getModulesByPath().get("testcode");
    assertThat(m.isCommonJs()).isTrue();
}
Also used : ModuleMetadata(com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata) Test(org.junit.Test)

Aggregations

ModuleMetadata (com.google.javascript.jscomp.modules.ModuleMetadataMap.ModuleMetadata)61 Test (org.junit.Test)47 Name (com.google.javascript.jscomp.GlobalNamespace.Name)12 Node (com.google.javascript.rhino.Node)5 GatherModuleMetadata (com.google.javascript.jscomp.GatherModuleMetadata)2 Module (com.google.javascript.jscomp.modules.Module)2 BasicErrorManager (com.google.javascript.jscomp.BasicErrorManager)1 CheckLevel (com.google.javascript.jscomp.CheckLevel)1 Compiler (com.google.javascript.jscomp.Compiler)1 CompilerOptions (com.google.javascript.jscomp.CompilerOptions)1 JSError (com.google.javascript.jscomp.JSError)1 GlobalizedModuleName (com.google.javascript.jscomp.ModuleRenaming.GlobalizedModuleName)1 SourceFile (com.google.javascript.jscomp.SourceFile)1 ModuleLoader (com.google.javascript.jscomp.deps.ModuleLoader)1 Binding (com.google.javascript.jscomp.modules.Binding)1 ModuleMetadataMap (com.google.javascript.jscomp.modules.ModuleMetadataMap)1 Config (com.google.javascript.jscomp.parsing.Config)1 ParserRunner (com.google.javascript.jscomp.parsing.ParserRunner)1 Comment (com.google.javascript.jscomp.parsing.parser.trees.Comment)1 InputId (com.google.javascript.rhino.InputId)1