Пример #1
0
  @Test
  @Category({P1, FAST, UNIT})
  @Description("Test Ctype mixin with mtype. check the package and type information.")
  public void testMixin() {
    CompilationUnitDeclaration ast = prepareAst("mixinTranslatorTestFile.js.txt", null);
    //		ITypeManager typeManager1 = ctx.getTypeManager();
    IJstType jstType = SyntaxTreeFactory2.createJST(ast, ctx);
    assertNotNull(jstType);
    //		ITypeManager typeManager2 = ctx.getTypeManager();

    //		assertTrue(typeManager1.equals(typeManager2));

    assertEquals("com.ebay.vjet", jstType.getPackage().getName());
    assertEquals("A", jstType.getSimpleName());

    List<? extends IJstTypeReference> mixins = jstType.getMixinsRef();
    assertNotNull(mixins);
    assertEquals(2, mixins.size());

    IJstType mixin = mixins.get(0).getReferencedType();
    assertTrue(mixin.isMixin());
    IJstType mixin2 = mixins.get(1).getReferencedType();
    assertTrue(mixin2.isMixin());

    assertEquals("com.ebay.vjet.fld", mixin.getPackage().getName());
    assertEquals("B", mixin.getSimpleName());
    assertEquals(3, mixin.getMethods().size());
    assertEquals(4, JstTypeHelper.getDeclaredProperties(mixin.getProperties()).size());
  }
Пример #2
0
  @Before
  public void prepareTest() {
    CompilationUnitDeclaration ast = prepareAst("mTypeTranslatorTestFile.txt", null);
    ctx = new TranslateCtx();
    mtype = SyntaxTreeFactory2.createJST(ast, ctx);
    assertNotNull(mtype);

    // add to cache

    JstCache.getInstance().addType((JstType) mtype);

    CompilationUnitDeclaration ast2 = prepareAst("mTypeCTranslatorTestFile.txt", null);
    ctx2 = new TranslateCtx();
    mtype2 = SyntaxTreeFactory2.createJST(ast2, ctx2);
    assertNotNull(mtype2);

    // add to cache
    JstCache.getInstance().addType((JstType) mtype2);
  }
Пример #3
0
 @Test
 @Category({P1, FAST, UNIT})
 @Description(
     "Test incomplete VJET itype should parse non-null jst. "
         + "Also it should have bare minimum information baout vjet type")
 public void testProcessIType() {
   CompilationUnitDeclaration ast = prepareAst("iTypeTranslatorTestFile.txt", null);
   IJstType jstType = SyntaxTreeFactory2.createJST(ast, new TranslateCtx());
   assertNotNull(jstType);
   assertTrue(jstType.isInterface());
 }
Пример #4
0
  @Test
  @Category({P1, FAST, UNIT})
  @Description(
      "Test VJET mtype should parse non-null jst. "
          + "Also it should have required statements and expressions in jst type")
  public void testProcessMType() {
    CompilationUnitDeclaration ast = prepareAst("mTypeTranslatorTestFile.txt", null);
    IJstType jstType = SyntaxTreeFactory2.createJST(ast, new TranslateCtx());

    assertNotNull(jstType);
    assertTrue(jstType.isMixin());
  }
Пример #5
0
  @Test
  @Category({P5, FAST, UNIT})
  @Description(
      "Test incomplete VJET atype should parse non-null jst. "
          + "Also it should have bare minimum information baout vjet type")
  public void testProcessType1() {
    CompilationUnitDeclaration ast = prepareAst("typeTranslatorTestFile.js.txt", null);
    IJstType jstType = SyntaxTreeFactory2.createJST(ast, new TranslateCtx());

    List<? extends IJstMethod> staticMethods = jstType.getStaticMethods();
    assertNotNull(staticMethods);
    assertEquals(2, JstTypeHelper.getDeclaredMethods(staticMethods).size());
    IJstMethod jstMethod = getMethodByName(staticMethods, "getRate");
    assertNotNull(jstMethod);
    IJstMethod jstMethod2 = getMethodByName(staticMethods, "getDiscount");
    assertNotNull(jstMethod2);
    assertNotNull(jstType.getMethod("chase"));
  }
Пример #6
0
  @Test // @Description("Partial Mtype JS file should produce meaningful JSTType. " +
  //	"Type name and package should be proper along with expects for itype")
  public void testExpects() {
    CompilationUnitDeclaration ast = prepareAst("expectsTranslatorTestFile.js.txt", null);

    IJstType jstType = SyntaxTreeFactory2.createJST(ast, new TranslateCtx());
    assertNotNull(jstType);
    assertTrue(jstType.isMixin());

    assertEquals("com.ebay.vjet", jstType.getPackage().getName());
    assertEquals("M", jstType.getSimpleName());

    List<? extends IJstType> expects = jstType.getExpects();
    assertNotNull(expects);
    assertEquals(1, expects.size());

    assertEquals("com.ebay.vjet", expects.get(0).getPackage().getName());
    assertEquals("I", expects.get(0).getSimpleName());
  }