Skip to content

Commit

Permalink
Migrates "test/com/google/javascript/jscomp/*.java" to use JUnit4 run…
Browse files Browse the repository at this point in the history
…ner and annotations.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213062609
  • Loading branch information
nreid260 authored and tjgq committed Sep 18, 2018
1 parent 32086bf commit b725574
Show file tree
Hide file tree
Showing 10 changed files with 511 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
package com.google.javascript.jscomp;

import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* Test case for {@link Es6ToEs3ClassSideInheritance}.
*
* @author tbreisacher@google.com (Tyler Breisacher)
*/
@RunWith(JUnit4.class)
public class Es6ToEs3ClassSideInheritanceTest extends CompilerTestCase {
@Override
@Before
public void setUp() throws Exception {
super.setUp();
setAcceptedLanguage(LanguageMode.ECMASCRIPT_2015);
Expand All @@ -41,6 +47,7 @@ protected int getNumRepetitions() {
return 1;
}

@Test
public void testSimple() {
test(
lines(
Expand All @@ -67,6 +74,7 @@ public void testSimple() {
"Subclass.staticMethod = Example.staticMethod;"));
}

@Test
public void testTyped() {
test(
lines(
Expand Down Expand Up @@ -96,7 +104,7 @@ public void testTyped() {
"Subclass.staticMethod = Example.staticMethod;"));
}


@Test
public void testNestedSubclass() {
test(
lines(
Expand Down Expand Up @@ -133,6 +141,7 @@ public void testNestedSubclass() {
"A.e = 42;"));
}

@Test
public void testOverride() {
testSame(
lines(
Expand Down Expand Up @@ -161,9 +170,8 @@ public void testOverride() {
"Subclass.staticProp = 6;"));
}

/**
* In this example, the base class has a static field which is not a function.
*/
/** In this example, the base class has a static field which is not a function. */
@Test
public void testStaticNonMethod() {
test(
lines(
Expand Down Expand Up @@ -193,6 +201,7 @@ public void testStaticNonMethod() {
"Subclass.staticField = Example.staticField;"));
}

@Test
public void testGetterSetterSimple() {
// This is what the Es6ToEs3Converter produces for:
//
Expand Down Expand Up @@ -241,6 +250,7 @@ public void testGetterSetterSimple() {
"$jscomp.inherits(Subclass, Example);"));
}

@Test
public void testGetterSetterQualifiedClassName() {
test(
lines(
Expand Down Expand Up @@ -276,9 +286,10 @@ public void testGetterSetterQualifiedClassName() {
}

/**
* In this case the stub is not really a stub. It's just a no-op getter, we would be able to
* In this case the stub is not really a stub. It's just a no-op getter, we would be able to
* detect this and not copy the stub since there is a member with this name.
*/
@Test
public void testGetterSetterFakeStub() {
test(
lines(
Expand Down Expand Up @@ -309,6 +320,7 @@ public void testGetterSetterFakeStub() {
"B.property = A.property;"));
}

@Test
public void testGetterSetterSubclassSubclass() {
test(
lines(
Expand Down Expand Up @@ -357,9 +369,8 @@ public void testGetterSetterSubclassSubclass() {
""));
}

/**
* If the subclass overrides the property we don't want to redeclare the stub.
*/
/** If the subclass overrides the property we don't want to redeclare the stub. */
@Test
public void testGetterSetterSubclassOverride() {
testSame(
lines(
Expand Down Expand Up @@ -406,6 +417,7 @@ public void testGetterSetterSubclassOverride() {
""));
}

@Test
public void testGetterSetter_noType() {
test(
lines(
Expand Down Expand Up @@ -441,6 +453,7 @@ public void testGetterSetter_noType() {
"$jscomp.inherits(Subclass, Example);"));
}

@Test
public void testInheritFromExterns() {
test(
externs(
Expand Down Expand Up @@ -468,6 +481,7 @@ public void testInheritFromExterns() {
"CodeClass.m = ExternsClass.m;")));
}

@Test
public void testAliasing() {
test(
lines(
Expand Down Expand Up @@ -536,6 +550,7 @@ public void testAliasing() {
"Bar.prop = Foo.prop;"));
}

@Test
public void testScopeHandling() {
testSame(
lines(
Expand Down Expand Up @@ -579,6 +594,7 @@ public void testScopeHandling() {
"$jscomp.inherits(Bar, Foo);"));
}

@Test
public void testInlineTypes() {
test(
lines(
Expand All @@ -604,9 +620,8 @@ public void testInlineTypes() {
"B.foo = A.foo;"));
}

/**
* Examples which are handled incorrectly but are unlikely to come up in practice.
*/
/** Examples which are handled incorrectly but are unlikely to come up in practice. */
@Test
public void testIncorrectScopeHandling() {
test(
lines(
Expand Down

0 comments on commit b725574

Please sign in to comment.