本文整理汇总了Java中com.google.javascript.rhino.testing.BaseJSTypeTestCase类的典型用法代码示例。如果您正苦于以下问题:Java BaseJSTypeTestCase类的具体用法?Java BaseJSTypeTestCase怎么用?Java BaseJSTypeTestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseJSTypeTestCase类属于com.google.javascript.rhino.testing包,在下文中一共展示了BaseJSTypeTestCase类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testIgnoreUnknownType
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testIgnoreUnknownType() {
String js = ""
+ "/** @constructor */\n"
+ "function Foo() {}\n"
+ "Foo.prototype.blah = 3;\n"
+ "/** @type {Foo} */\n"
+ "var F = new Foo;\n"
+ "F.blah = 0;\n"
+ "var U = function() { return {} };\n"
+ "U().blah();";
String expected = ""
+ "function Foo(){}Foo.prototype.blah=3;var F = new Foo;F.blah=0;"
+ "var U=function(){return{}};U().blah()";
testSets(false, js, expected, "{}");
testSets(true, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
js, expected, "{}");
}
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:DisambiguatePropertiesTest.java
示例2: testUnresolvedType
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testUnresolvedType() {
String js = ""
+ "var g = {};"
+ "/** @constructor \n @extends g.NotHere */ var Foo = function() {}\n"
+ "Foo.prototype.a = 0;"
+ "/** @constructor */ var Bar = function() {}\n"
+ "Bar.prototype.a = 0;";
String output = ""
+ "var g={};"
+ "var Foo=function(){};"
+ "Foo.prototype.Foo_prototype$a=0;"
+ "var Bar=function(){};"
+ "Bar.prototype.Bar_prototype$a=0;";
testSets(false, js, js, "{}");
testSets(true, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
js, output, "{a=[[Bar.prototype], [Foo.prototype]]}");
}
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:DisambiguatePropertiesTest.java
示例3: testUnknownType
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testUnknownType() {
String js = ""
+ "/** @constructor */ var Foo = function() {};\n"
+ "/** @constructor */ var Bar = function() {};\n"
+ "function fun() {}\n"
+ "Foo.prototype.a = fun();\n"
+ "fun().a;\n"
+ "Bar.prototype.a = 0;";
String ttOutput = ""
+ "var Foo=function(){};\n"
+ "var Bar=function(){};\n"
+ "function fun(){}\n"
+ "Foo.prototype.Foo_prototype$a=fun();\n"
+ "fun().Unique$1$a;\n"
+ "Bar.prototype.Bar_prototype$a=0;";
testSets(false, js, js, "{}");
testSets(true, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES, js, ttOutput,
"{a=[[Bar.prototype], [Foo.prototype], [Unique$1]]}");
}
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:DisambiguatePropertiesTest.java
示例4: test
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
/**
* Verifies that the compiler pass's JS output matches the expected output
* and (optionally) that an expected warning is issued. Or, if an error is
* expected, this method just verifies that the error is encountered.
*
* @param externs Externs inputs
* @param js Input
* @param expected Expected output, or null if an error is expected
* @param error Expected error, or null if no error is expected
* @param warning Expected warning, or null if no warning is expected
* @param description The description of the expected warning,
* or null if no warning is expected or if the warning's description
* should not be examined
*/
public void test(JSSourceFile[] externs, String js, String expected,
DiagnosticType error,
DiagnosticType warning, String description) {
Compiler compiler = createCompiler();
lastCompiler = compiler;
BaseJSTypeTestCase.addNativeProperties(compiler.getTypeRegistry());
CompilerOptions options = getOptions();
// Note that in this context, turning on the checkTypes option won't
// actually cause the type check to run.
options.checkTypes = parseTypeInfo;
compiler.init(externs, new JSSourceFile[] {
JSSourceFile.fromCode("testcode", js) }, options);
test(compiler, new String[] { expected }, error, warning, description);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:31,代码来源:CompilerTestCase.java
示例5: testUnknownType
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testUnknownType() {
String js = ""
+ "/** @constructor */ var Foo = function() {};\n"
+ "/** @constructor */ var Bar = function() {};\n"
+ "/** @return {?} */ function fun() {}\n"
+ "Foo.prototype.a = fun();\n"
+ "fun().a;\n"
+ "Bar.prototype.a = 0;";
String ttOutput = ""
+ "var Foo=function(){};\n"
+ "var Bar=function(){};\n"
+ "function fun(){}\n"
+ "Foo.prototype.Foo_prototype$a=fun();\n"
+ "fun().Unique$1$a;\n"
+ "Bar.prototype.Bar_prototype$a=0;";
testSets(false, js, js, "{}");
testSets(true, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES, js, ttOutput,
"{a=[[Bar.prototype], [Foo.prototype], [Unique$1]]}");
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:20,代码来源:DisambiguatePropertiesTest.java
示例6: test
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
/**
* Verifies that the compiler pass's JS output matches the expected output
* and (optionally) that an expected warning is issued. Or, if an error is
* expected, this method just verifies that the error is encountered.
*
* @param externs Externs inputs
* @param js Input
* @param expected Expected output, or null if an error is expected
* @param error Expected error, or null if no error is expected
* @param warning Expected warning, or null if no warning is expected
* @param description The description of the expected warning,
* or null if no warning is expected or if the warning's description
* should not be examined
*/
public void test(JSSourceFile[] externs, String js, String expected,
DiagnosticType error,
DiagnosticType warning, String description) {
Compiler compiler = createCompiler();
lastCompiler = compiler;
CompilerOptions options = getOptions();
// Note that in this context, turning on the checkTypes option won't
// actually cause the type check to run.
options.checkTypes = parseTypeInfo;
compiler.init(externs, new JSSourceFile[] {
JSSourceFile.fromCode("testcode", js) }, options);
BaseJSTypeTestCase.addNativeProperties(compiler.getTypeRegistry());
test(compiler, new String[] { expected }, error, warning, description);
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:32,代码来源:CompilerTestCase.java
示例7: testExternSubTypesForObject
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testExternSubTypesForObject() {
testSame(BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES
+ "/** @constructor */ function A() {};\n"
+ "/** @constructor \[email protected] A */ function B() {};\n"
+ "/** @return {Object} */ "
+ "Object.prototype.eval = function(code) {};\n"
+ "/** @type {Object} */\n"
+ "A.prototype.a;\n"
+ "/** @return {Object} */\n"
+ "A.prototype.b = function(){};\n",
"var a = (new A).b()", null, null);
assertType("(A,ActiveXObject,Array,B,Boolean,Date,Error,EvalError,"
+ "Function,Number,Object,"
+ "RangeError,ReferenceError,RegExp,String,SyntaxError,"
+ "TypeError,URIError)", getType("a"));
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:17,代码来源:TightenTypesTest.java
示例8: testIgnoreUnknownType1
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testIgnoreUnknownType1() {
String js = ""
+ "/** @constructor */\n"
+ "function Foo() {}\n"
+ "Foo.prototype.blah = 3;\n"
+ "/** @type {Foo} */\n"
+ "var F = new Foo;\n"
+ "F.blah = 0;\n"
+ "/** @return {Object} */\n"
+ "var U = function() { return {} };\n"
+ "U().blah();";
String expected = ""
+ "function Foo(){}Foo.prototype.blah=3;var F = new Foo;F.blah=0;"
+ "var U=function(){return{}};U().blah()";
testSets(false, js, expected, "{blah=[[Foo.prototype]]}");
testSets(true, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
js, expected, "{}");
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:DisambiguatePropertiesTest.java
示例9: testIgnoreUnknownType2
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testIgnoreUnknownType2() {
String js = ""
+ "/** @constructor */\n"
+ "function Foo() {}\n"
+ "Foo.prototype.blah = 3;\n"
+ "/** @type {Foo} */\n"
+ "var F = new Foo;\n"
+ "F.blah = 0;\n"
+ "/** @constructor */\n"
+ "function Bar() {}\n"
+ "Bar.prototype.blah = 3;\n"
+ "/** @return {Object} */\n"
+ "var U = function() { return {} };\n"
+ "U().blah();";
String expected = ""
+ "function Foo(){}Foo.prototype.blah=3;var F = new Foo;F.blah=0;"
+ "function Bar(){}Bar.prototype.blah=3;"
+ "var U=function(){return{}};U().blah()";
testSets(false, js, expected, "{}");
testSets(true, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
js, expected, "{}");
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:DisambiguatePropertiesTest.java
示例10: testUnresolvedType
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testUnresolvedType() {
// NOTE(nicksantos): This behavior seems very wrong to me.
String js = ""
+ "var g = {};"
+ "/** @constructor \n @extends {?} */ "
+ "var Foo = function() {};\n"
+ "Foo.prototype.a = 0;"
+ "/** @constructor */ var Bar = function() {};\n"
+ "Bar.prototype.a = 0;";
String output = ""
+ "var g={};"
+ "var Foo=function(){};"
+ "Foo.prototype.Foo_prototype$a=0;"
+ "var Bar=function(){};"
+ "Bar.prototype.Bar_prototype$a=0;";
testSets(false, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
js, output, "{a=[[Bar.prototype], [Foo.prototype]]}");
testSets(true, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
js, output, "{a=[[Bar.prototype], [Foo.prototype]]}");
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:DisambiguatePropertiesTest.java
示例11: test
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
/**
* Verifies that the compiler pass's JS output matches the expected output
* and (optionally) that an expected warning is issued. Or, if an error is
* expected, this method just verifies that the error is encountered.
*
* @param externs Externs inputs
* @param js Input
* @param expected Expected output, or null if an error is expected
* @param error Expected error, or null if no error is expected
* @param warning Expected warning, or null if no warning is expected
* @param description The description of the expected warning,
* or null if no warning is expected or if the warning's description
* should not be examined
*/
public void test(List<SourceFile> externs, String js, String expected,
DiagnosticType error,
DiagnosticType warning, String description) {
Compiler compiler = createCompiler();
lastCompiler = compiler;
CompilerOptions options = getOptions();
if (this.acceptES5) {
options.setLanguageIn(LanguageMode.ECMASCRIPT5);
}
// Note that in this context, turning on the checkTypes option won't
// actually cause the type check to run.
options.checkTypes = parseTypeInfo;
compiler.init(externs, ImmutableList.of(
SourceFile.fromCode(filename, js)), options);
BaseJSTypeTestCase.addNativeProperties(compiler.getTypeRegistry());
test(compiler, maybeCreateArray(expected), error, warning, description);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:36,代码来源:CompilerTestCase.java
示例12: testInternal
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
protected void testInternal(
Externs externs,
Sources inputs,
Expected expected,
Diagnostic diagnostic,
List<Postcondition> postconditions) {
Compiler compiler = createCompiler();
lastCompiler = compiler;
CompilerOptions options = getOptions();
if (inputs instanceof FlatSources) {
options.setCheckTypes(parseTypeInfo || this.typeCheckEnabled);
compiler.init(externs.externs, ((FlatSources) inputs).sources, options);
} else {
compiler.initModules(externsInputs, ((ModuleSources) inputs).modules, getOptions());
}
if (this.typeCheckEnabled) {
BaseJSTypeTestCase.addNativeProperties(compiler.getTypeRegistry());
}
testInternal(compiler, inputs, expected, diagnostic, postconditions);
}
开发者ID:google,项目名称:closure-compiler,代码行数:26,代码来源:CompilerTestCase.java
示例13: testUnresolvedType
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testUnresolvedType() {
// NOTE(nicksantos): This behavior seems very wrong to me.
String js = ""
+ "var g = {};"
+ "/** @constructor \n @extends {?} */ "
+ "var Foo = function() {};\n"
+ "Foo.prototype.a = 0;"
+ "/** @constructor */ var Bar = function() {};\n"
+ "Bar.prototype.a = 0;";
String output = ""
+ "var g={};"
+ "var Foo=function(){};"
+ "Foo.prototype.Foo_prototype$a=0;"
+ "var Bar=function(){};"
+ "Bar.prototype.Bar_prototype$a=0;";
setExpectParseWarningsThisTest();
testSets(BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES, js,
output, "{a=[[Bar.prototype], [Foo.prototype]]}");
}
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:21,代码来源:DisambiguatePropertiesTest.java
示例14: testUnresolvedType
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testUnresolvedType() {
// NOTE(nicksantos): This behavior seems very wrong to me.
String js = ""
+ "var g = {};"
+ "/** @constructor \n @extends {?} */ "
+ "var Foo = function() {};\n"
+ "Foo.prototype.a = 0;"
+ "/** @constructor */ var Bar = function() {};\n"
+ "Bar.prototype.a = 0;";
String output = ""
+ "var g={};"
+ "var Foo=function(){};"
+ "Foo.prototype.Foo_prototype$a=0;"
+ "var Bar=function(){};"
+ "Bar.prototype.Bar_prototype$a=0;";
setExpectParseWarningsThisTest();
testSets(false, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
js, output, "{a=[[Bar.prototype], [Foo.prototype]]}");
testSets(true, BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
js, output, "{a=[[Bar.prototype], [Foo.prototype]]}");
}
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:23,代码来源:DisambiguatePropertiesTest.java
示例15: testUntypedExterns
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testUntypedExterns() {
String externs =
BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES
+ "var window;"
+ "window.alert = function() {x};";
String js = ""
+ "/** @constructor */ function Foo() {}\n"
+ "Foo.prototype.a = 0;\n"
+ "Foo.prototype.alert = 0;\n"
+ "Foo.prototype.window = 0;\n"
+ "/** @constructor */ function Bar() {}\n"
+ "Bar.prototype.a = 0;\n"
+ "Bar.prototype.alert = 0;\n"
+ "Bar.prototype.window = 0;\n"
+ "window.alert();";
String output = ""
+ "function Foo(){}"
+ "Foo.prototype.Foo_prototype$a=0;"
+ "Foo.prototype.alert=0;"
+ "Foo.prototype.Foo_prototype$window=0;"
+ "function Bar(){}"
+ "Bar.prototype.Bar_prototype$a=0;"
+ "Bar.prototype.alert=0;"
+ "Bar.prototype.Bar_prototype$window=0;"
+ "window.alert();";
testSets(false, externs, js, output, "{a=[[Bar.prototype], [Foo.prototype]]"
+ ", window=[[Bar.prototype], [Foo.prototype]]}");
testSets(true, externs, js, output, "{a=[[Bar.prototype], [Foo.prototype]],"
+ " window=[[Bar.prototype], [Foo.prototype]]}");
}
开发者ID:andyjko,项目名称:feedlack,代码行数:32,代码来源:DisambiguatePropertiesTest.java
示例16: testCatchStatement
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testCatchStatement() {
testSame(BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
"/** @constructor */ function Bar() {}\n"
+ "function bar() { try { } catch (e) { return e; } }\n"
+ "/** @constructor\[email protected]{Error}*/ function ID10TError() {}\n"
+ "var a = bar(); throw new ID10TError();\n", null, null);
assertType("(Error,EvalError,ID10TError,RangeError,ReferenceError,"
+ "SyntaxError,TypeError,URIError)", getType("a"));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:11,代码来源:TightenTypesTest.java
示例17: testGetElem3
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testGetElem3() {
testSame(BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES,
"/** @constructor */ function Foo() {}\n"
+ "/** @constructor */ function Bar() {}\n"
+ "/** @constructor */ function Baz() {\n"
+ " this.arr = [];\n"
+ "}\n"
+ "function foo(anarr) {"
+ "}\n"
+ "var ar = [];\n"
+ "foo(ar);\n", null);
assertType("Array", getType("ar"));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:15,代码来源:TightenTypesTest.java
示例18: testExternSubTypesForObject
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testExternSubTypesForObject() {
testSame(BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES
+ "/** @constructor */ function A() {};\n"
+ "/** @constructor \[email protected] A */ function B() {};\n"
+ "/** @return {Object} */ Object.prototype.eval = function(code) {};\n"
+ "/** @type {Object} */\n"
+ "A.prototype.a;\n"
+ "/** @return {Object} */\n"
+ "A.prototype.b = function(){};\n",
"var a = (new A).b()", null, null);
assertType("(A,Array,B,Boolean,Date,Error,EvalError,Function,Number,Object,"
+ "RangeError,ReferenceError,RegExp,String,SyntaxError,"
+ "TypeError,URIError)", getType("a"));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:15,代码来源:TightenTypesTest.java
示例19: testUntypedExterns
import com.google.javascript.rhino.testing.BaseJSTypeTestCase; //导入依赖的package包/类
public void testUntypedExterns() {
String externs =
BaseJSTypeTestCase.ALL_NATIVE_EXTERN_TYPES
+ "var window;"
+ "window.alert = function() {x};";
String js = ""
+ "/** @constructor */ function Foo() {}\n"
+ "Foo.prototype.a = 0;\n"
+ "Foo.prototype.alert = 0;\n"
+ "Foo.prototype.window = 0;\n"
+ "/** @constructor */ function Bar() {}\n"
+ "Bar.prototype.a = 0;\n"
+ "Bar.prototype.alert = 0;\n"
+ "Bar.prototype.window = 0;\n"
+ "window.alert();";
String output = ""
+ "function Foo(){}"
+ "Foo.prototype.Foo_prototype$a=0;"
+ "Foo.prototype.alert=0;"
+ "Foo.prototype.Foo_prototype$window=0;"
+ "function Bar(){}"
+ "Bar.prototype.Bar_prototype$a=0;"
+ "Bar.prototype.alert=0;"
+ "Bar.prototype.Bar_prototype$window=0;"
+ "window.alert();";
testSets(externs, js, output, "{a=[[Bar.prototype], [Foo.prototype]]"
+ ", window=[[Bar.prototype], [Foo.prototype]]}");
}
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:30,代码来源:DisambiguatePropertiesTest.java
注:本文中的com.google.javascript.rhino.testing.BaseJSTypeTestCase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论