当前位置: 首页>>代码示例>>Java>>正文


Java Asserts.assertTypeEquals方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.testing.Asserts.assertTypeEquals方法的典型用法代码示例。如果您正苦于以下问题:Java Asserts.assertTypeEquals方法的具体用法?Java Asserts.assertTypeEquals怎么用?Java Asserts.assertTypeEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.testing.Asserts的用法示例。


在下文中一共展示了Asserts.assertTypeEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNamespacedFunctionStubLocal

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testNamespacedFunctionStubLocal() {
  testSame(
      "(function() {" +
      "var goog = {};" +
      "/** @param {number} x */ goog.foo;" +
      "});");

  ObjectType goog = (ObjectType) findNameType("goog", lastLocalScope);
  assertTrue(goog.hasProperty("foo"));
  assertEquals("function(number): ?",
      goog.getPropertyType("foo").toString());
  assertTrue(goog.isPropertyTypeDeclared("foo"));

  Asserts.assertTypeEquals(lastLocalScope.getVar("goog.foo").getType(),
      goog.getPropertyType("foo"));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:TypedScopeCreatorTest.java

示例2: testPropertiesOnInterface

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testPropertiesOnInterface() throws Exception {
  testSame("/** @interface */ var I = function() {};" +
      "/** @type {number} */ I.prototype.bar;" +
      "I.prototype.baz = function(){};");

  Var i = globalScope.getVar("I");
  assertEquals("function (this:I): ?", i.getType().toString());
  assertTrue(i.getType().isInterface());

  ObjectType iPrototype = (ObjectType)
      ((ObjectType) i.getType()).getPropertyType("prototype");
  assertEquals("I.prototype", iPrototype.toString());
  assertTrue(iPrototype.isFunctionPrototypeType());

  assertEquals("number", iPrototype.getPropertyType("bar").toString());
  assertEquals("function (this:I): undefined",
      iPrototype.getPropertyType("baz").toString());

  Asserts.assertTypeEquals(iPrototype, globalScope.getVar("I.prototype").getType());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:TypedScopeCreatorTest.java

示例3: testNamespacedFunctionStubLocal

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testNamespacedFunctionStubLocal() {
  testSame(
      "(function() {" +
      "var goog = {};" +
      "/** @param {number} x */ goog.foo;" +
      "});");

  ObjectType goog = (ObjectType) findNameType("goog", lastLocalScope);
  assertTrue(goog.hasProperty("foo"));
  assertEquals("function (number): ?",
      goog.getPropertyType("foo").toString());
  assertTrue(goog.isPropertyTypeDeclared("foo"));

  Asserts.assertTypeEquals(lastLocalScope.getVar("goog.foo").getType(),
      goog.getPropertyType("foo"));
}
 
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:17,代码来源:TypedScopeCreatorTest.java

示例4: testEnumAlias

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testEnumAlias() {
  testSame("/** @enum */ var Foo = {BAR: 1}; " +
      "/** @enum */ var FooAlias = Foo; var f = FooAlias;");

  assertEquals("Foo<number>",
      registry.getType("FooAlias").toString());
  Asserts.assertTypeEquals(registry.getType("FooAlias"),
      registry.getType("Foo"));

  ObjectType f = (ObjectType) findNameType("f", globalScope);
  assertTrue(f.hasProperty("BAR"));
  assertEquals("Foo<number>", f.getPropertyType("BAR").toString());
  assertThat(f).isInstanceOf(EnumType.class);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:15,代码来源:TypedScopeCreatorTest.java

示例5: testGreatestSubtypeUnionTypes2

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests {@link JSType#getGreatestSubtype(JSType)} on union types.
 */
@SuppressWarnings("checked")
public void testGreatestSubtypeUnionTypes2() {
  UnionType evalUriError =
      (UnionType) createUnionType(EVAL_ERROR_TYPE, URI_ERROR_TYPE);
  Asserts.assertTypeEquals(evalUriError,
      evalUriError.getGreatestSubtype(ERROR_TYPE));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:UnionTypeTest.java

示例6: testStubProperty

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testStubProperty() {
  testSame("function Foo() {}; Foo.bar;");
  ObjectType foo = (ObjectType) globalScope.getVar("Foo").getType();
  assertFalse(foo.hasProperty("bar"));
  Asserts.assertTypeEquals(registry.getNativeType(UNKNOWN_TYPE),
      foo.getPropertyType("bar"));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:TypedScopeCreatorTest.java

示例7: testSupAndInf

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testSupAndInf() {
  JSType recordA = new RecordTypeBuilder(registry)
      .addProperty("a", NUMBER_TYPE, null)
      .addProperty("b", NUMBER_TYPE, null)
      .build();
  JSType recordC = new RecordTypeBuilder(registry)
      .addProperty("b", NUMBER_TYPE, null)
      .addProperty("c", NUMBER_TYPE, null)
      .build();
  ProxyObjectType proxyRecordA = new ProxyObjectType(registry, recordA);
  ProxyObjectType proxyRecordC = new ProxyObjectType(registry, recordC);

  JSType aInfC = new RecordTypeBuilder(registry)
      .addProperty("a", NUMBER_TYPE, null)
      .addProperty("b", NUMBER_TYPE, null)
      .addProperty("c", NUMBER_TYPE, null)
      .build();

  JSType aSupC = registry.createUnionType(recordA, recordC);

  Asserts.assertTypeEquals(
      aInfC, recordA.getGreatestSubtype(recordC));
  Asserts.assertTypeEquals(
      aSupC, recordA.getLeastSupertype(recordC));

  Asserts.assertTypeEquals(
      aInfC, proxyRecordA.getGreatestSubtype(proxyRecordC));
  Asserts.assertTypeEquals(
      aSupC, proxyRecordA.getLeastSupertype(proxyRecordC));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:31,代码来源:RecordTypeTest.java

示例8: testNamespacedFunctionStub

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testNamespacedFunctionStub() {
  testSame(
      "var goog = {};" +
      "/** @param {number} x */ goog.foo;");

  ObjectType goog = (ObjectType) findNameType("goog", globalScope);
  assertTrue(goog.hasProperty("foo"));
  assertEquals("function(number): ?",
      goog.getPropertyType("foo").toString());
  assertTrue(goog.isPropertyTypeDeclared("foo"));

  Asserts.assertTypeEquals(globalScope.getVar("goog.foo").getType(),
      goog.getPropertyType("foo"));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:15,代码来源:TypedScopeCreatorTest.java

示例9: testClosureFunction

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
private void testClosureFunction(String function, JSType type,
    JSType trueType, JSType falseType) {
  // function(a) where a : type
  Node n = compiler.parseTestCode("var a; " + function + "(a)");
  Node call = n.getLastChild().getLastChild();
  Node name = call.getLastChild();

  Scope scope = new SyntacticScopeCreator(compiler).createScope(n, null);
  FlowScope flowScope = LinkedFlowScope.createEntryLattice(scope);

  assertEquals(Token.CALL, call.getType());
  assertEquals(Token.NAME, name.getType());

  GoogleCodingConvention convention = new GoogleCodingConvention();
  flowScope.inferSlotType("a", type);
  ClosureReverseAbstractInterpreter rai =
      new ClosureReverseAbstractInterpreter(convention, registry);

  // trueScope
  Asserts.assertTypeEquals(
      trueType,
      rai.getPreciserScopeKnowingConditionOutcome(call, flowScope, true)
      .getSlot("a").getType());

  // falseScope
  Asserts.assertTypeEquals(
      falseType,
      rai.getPreciserScopeKnowingConditionOutcome(call, flowScope, false)
      .getSlot("a").getType());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:31,代码来源:ClosureReverseAbstractInterpreterTest.java

示例10: testStubProperty

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testStubProperty() {
  testSame("function Foo() {}; Foo.bar;");
  ObjectType foo = (ObjectType) globalScope.getVar("Foo").getType();
  assertFalse(foo.hasProperty("bar"));
  Asserts.assertTypeEquals(registry.getNativeType(UNKNOWN_TYPE),
      foo.getPropertyType("bar"));
  Asserts.assertTypeCollectionEquals(
      Lists.newArrayList(foo), registry.getTypesWithProperty("bar"));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:TypedScopeCreatorTest.java

示例11: testClosureFunction

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
private void testClosureFunction(String function, JSType type,
    JSType trueType, JSType falseType) {
  // function(a) where a : type
  Node n = compiler.parseTestCode("var a; " + function + "(a)");
  Node call = n.getLastChild().getLastChild();
  Node name = call.getLastChild();

  TypedScope scope = (TypedScope) SyntacticScopeCreator.makeTyped(compiler).createScope(n, null);
  FlowScope flowScope = LinkedFlowScope.createEntryLattice(scope);

  assertEquals(Token.CALL, call.getToken());
  assertEquals(Token.NAME, name.getToken());

  flowScope.inferSlotType("a", type);
  ClosureReverseAbstractInterpreter rai =
      new ClosureReverseAbstractInterpreter(registry);

  // trueScope
  Asserts.assertTypeEquals(
      trueType,
      rai.getPreciserScopeKnowingConditionOutcome(call, flowScope, true)
      .getSlot("a").getType());

  // falseScope
  Asserts.assertTypeEquals(
      falseType,
      rai.getPreciserScopeKnowingConditionOutcome(call, flowScope, false)
      .getSlot("a").getType());
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:30,代码来源:ClosureReverseAbstractInterpreterTest.java

示例12: testNamespacesEnumAlias

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testNamespacesEnumAlias() {
  testSame("var goog = {}; /** @enum */ goog.Foo = {BAR: 1}; " +
      "/** @enum */ goog.FooAlias = goog.Foo;");

  assertEquals("goog.Foo.<number>",
      registry.getType("goog.FooAlias").toString());
  Asserts.assertTypeEquals(registry.getType("goog.Foo"),
      registry.getType("goog.FooAlias"));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:TypedScopeCreatorTest.java

示例13: testNamespacedFunctionStub

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testNamespacedFunctionStub() {
  testSame(
      "var goog = {};" +
      "/** @param {number} x */ goog.foo;");

  ObjectType goog = (ObjectType) findNameType("goog", globalScope);
  assertTrue(goog.hasProperty("foo"));
  assertEquals("function (number): ?",
      goog.getPropertyType("foo").toString());
  assertTrue(goog.isPropertyTypeDeclared("foo"));

  Asserts.assertTypeEquals(globalScope.getVar("goog.foo").getType(),
      goog.getPropertyType("foo"));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:15,代码来源:TypedScopeCreatorTest.java

示例14: testGreatestSubtypeUnionTypes3

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
/**
 * Tests {@link JSType#getGreatestSubtype(JSType)} on union types.
 */
@SuppressWarnings("checked")
public void testGreatestSubtypeUnionTypes3() {
  // (number,undefined,null)
  UnionType nullableOptionalNumber =
      (UnionType) createUnionType(NULL_TYPE, VOID_TYPE, NUMBER_TYPE);
  // (null,undefined)
  UnionType nullUndefined =
      (UnionType) createUnionType(VOID_TYPE, NULL_TYPE);
  Asserts.assertTypeEquals(nullUndefined,
      nullUndefined.getGreatestSubtype(nullableOptionalNumber));
  Asserts.assertTypeEquals(nullUndefined,
      nullableOptionalNumber.getGreatestSubtype(nullUndefined));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:UnionTypeTest.java

示例15: testNamespacedConstructorAlias

import com.google.javascript.rhino.testing.Asserts; //导入方法依赖的package包/类
public void testNamespacedConstructorAlias() {
  testSame(
      "var goog = {};" +
      "/** @constructor */ goog.Foo = function() {};" +
      "/** @constructor */ goog.FooAlias = goog.Foo;");
  assertEquals("goog.Foo", registry.getType("goog.FooAlias").toString());
  Asserts.assertTypeEquals(registry.getType("goog.Foo"),
      registry.getType("goog.FooAlias"));
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:10,代码来源:TypedScopeCreatorTest.java


注:本文中的com.google.javascript.rhino.testing.Asserts.assertTypeEquals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。