Skip to content

Commit e288687

Browse files
shickslauraharker
authored andcommitted
[NTI] Teach TypeICompilerTestCase to run testExternChanges in both OTI and NTI.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=168072759
1 parent 70bf716 commit e288687

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/com/google/javascript/jscomp/TypeICompilerTestCase.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ protected void testInternal(
8888
}
8989
}
9090

91+
@Override
92+
protected void testExternChanges(String extern, String input, String expectedExtern,
93+
DiagnosticType... warnings) {
94+
if (this.mode.runsOTI()) {
95+
testExternChangesOTI(extern, input, expectedExtern, warnings);
96+
}
97+
if (this.mode.runsNTI()) {
98+
testExternChangesNTI(extern, input, expectedExtern, warnings);
99+
}
100+
if (this.mode.runsNeither()) {
101+
super.testExternChanges(extern, input, expectedExtern, warnings);
102+
}
103+
}
104+
91105
// Note: may be overridden to allow different externs if necessary.
92106
void checkMinimalExterns(Iterable<SourceFile> externs) {
93107
try {
@@ -134,6 +148,26 @@ private void testNTI(
134148
this.mode = saved;
135149
}
136150

151+
private void testExternChangesOTI(String extern, String input, String expectedExtern,
152+
DiagnosticType... warnings) {
153+
TypeInferenceMode saved = this.mode;
154+
this.mode = TypeInferenceMode.OTI_ONLY;
155+
enableTypeCheck();
156+
super.testExternChanges(extern, input, expectedExtern, warnings);
157+
disableTypeCheck();
158+
this.mode = saved;
159+
}
160+
161+
private void testExternChangesNTI(String extern, String input, String expectedExtern,
162+
DiagnosticType... warnings) {
163+
TypeInferenceMode saved = this.mode;
164+
this.mode = TypeInferenceMode.NTI_ONLY;
165+
enableNewTypeInference();
166+
super.testExternChanges(extern, input, expectedExtern, warnings);
167+
disableNewTypeInference();
168+
this.mode = saved;
169+
}
170+
137171
void testWarningOtiNti(
138172
String js, DiagnosticType otiWarning, DiagnosticType ntiWarning) {
139173
TypeInferenceMode saved = this.mode;

0 commit comments

Comments
 (0)