Skip to content

Commit

Permalink
Add some more tests for cr.define() handling, including a failing one…
Browse files Browse the repository at this point in the history
… for #2526

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158574746
  • Loading branch information
tbreisacher committed Jun 13, 2017
1 parent b9c6107 commit 2a6063b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/com/google/javascript/jscomp/ChromePassTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,41 @@ public void testCrDefineDoesntRedefineCrVar() throws Exception {
"cr.ui = cr.ui || {};\n" + "cr.define('cr.ui', function() {\n" + " return {};\n" + "});");
}

public void testCrDefineFunction() throws Exception {
test(
LINE_JOINER.join(
"cr.define('settings', function() {",
" var x = 0;",
" function C() {}",
" return { C: C };",
"});"),
LINE_JOINER.join(
"var settings = settings || {};",
"cr.define('settings', function() {",
" var x = 0;",
" settings.C = function C() {};",
" return { C: settings.C };",
"});"));
}

// Currently this throws an exception: https://github.com/google/closure-compiler/issues/2526
public void disabled_testCrDefineClass() throws Exception {
test(
LINE_JOINER.join(
"cr.define('settings', function() {",
" var x = 0;",
" class C {}",
" return { C: C };",
"});"),
LINE_JOINER.join(
"var settings = settings || {};",
"cr.define('settings', function() {",
" var x = 0;",
" settings.C = class C {}",
" return { C: C };",
"});"));
}

public void testCrExportPathInvalidNumberOfArguments() throws Exception {
testError("cr.exportPath();", ChromePass.CR_EXPORT_PATH_TOO_FEW_ARGUMENTS);
}
Expand Down

0 comments on commit 2a6063b

Please sign in to comment.