Add tests for equals, hashCode, toString in String and Number
This commit is contained in:
Generated
+10
@@ -17865,11 +17865,21 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/primitiveTypes/number.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/number.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("numberEqualsHashCodeToString.kt")
|
||||||
|
public void testNumberEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/numberEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("rangeTo.kt")
|
@TestMetadata("rangeTo.kt")
|
||||||
public void testRangeTo() throws Exception {
|
public void testRangeTo() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stringEqualsHashCodeToString.kt")
|
||||||
|
public void testStringEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/stringEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("substituteIntForGeneric.kt")
|
@TestMetadata("substituteIntForGeneric.kt")
|
||||||
public void testSubstituteIntForGeneric() throws Exception {
|
public void testSubstituteIntForGeneric() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
fun test(n: Number) {
|
||||||
|
if (!n.equals(n)) throw Error("fail 1 for $n")
|
||||||
|
if (n.equals(1)) throw Error("fail 2 for $n")
|
||||||
|
if (n.equals(1L)) throw Error("fail 3 for $n")
|
||||||
|
if (n != n) throw Error("fail 4 for $n")
|
||||||
|
if (n == 1) throw Error("fail 5 for $n")
|
||||||
|
if (n == 1L) throw Error("fail 6 for $n")
|
||||||
|
if (n.hashCode() != n.toInt()) throw Error("fail 7 for $n")
|
||||||
|
if (n.toString() != "$n") throw Error("fail 8 for $n")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
test(234)
|
||||||
|
test(546L)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
fun test(s: String) {
|
||||||
|
if (!s.equals(s)) throw Error("fail 1 for $s")
|
||||||
|
if (s.equals(1)) throw Error("fail 2 for $s")
|
||||||
|
if (s != s) throw Error("fail 4 for $s")
|
||||||
|
if (s == "111") throw Error("fail 5 for $s")
|
||||||
|
if (s.hashCode() != -1268878963) throw Error("fail 7 for $s")
|
||||||
|
if (s.toString() != "$s") throw Error("fail 8 for $s")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
test("foobar")
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+10
@@ -19381,11 +19381,21 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/primitiveTypes/number.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/number.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("numberEqualsHashCodeToString.kt")
|
||||||
|
public void testNumberEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/numberEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("rangeTo.kt")
|
@TestMetadata("rangeTo.kt")
|
||||||
public void testRangeTo() throws Exception {
|
public void testRangeTo() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stringEqualsHashCodeToString.kt")
|
||||||
|
public void testStringEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/stringEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("substituteIntForGeneric.kt")
|
@TestMetadata("substituteIntForGeneric.kt")
|
||||||
public void testSubstituteIntForGeneric() throws Exception {
|
public void testSubstituteIntForGeneric() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
||||||
|
|||||||
+10
@@ -19381,11 +19381,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/primitiveTypes/number.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/number.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("numberEqualsHashCodeToString.kt")
|
||||||
|
public void testNumberEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/numberEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("rangeTo.kt")
|
@TestMetadata("rangeTo.kt")
|
||||||
public void testRangeTo() throws Exception {
|
public void testRangeTo() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stringEqualsHashCodeToString.kt")
|
||||||
|
public void testStringEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/stringEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("substituteIntForGeneric.kt")
|
@TestMetadata("substituteIntForGeneric.kt")
|
||||||
public void testSubstituteIntForGeneric() throws Exception {
|
public void testSubstituteIntForGeneric() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
||||||
|
|||||||
+10
@@ -17865,11 +17865,21 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/primitiveTypes/number.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/number.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("numberEqualsHashCodeToString.kt")
|
||||||
|
public void testNumberEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/numberEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("rangeTo.kt")
|
@TestMetadata("rangeTo.kt")
|
||||||
public void testRangeTo() throws Exception {
|
public void testRangeTo() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stringEqualsHashCodeToString.kt")
|
||||||
|
public void testStringEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/stringEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("substituteIntForGeneric.kt")
|
@TestMetadata("substituteIntForGeneric.kt")
|
||||||
public void testSubstituteIntForGeneric() throws Exception {
|
public void testSubstituteIntForGeneric() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
||||||
|
|||||||
Generated
+10
@@ -14901,11 +14901,21 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/primitiveTypes/nullableCharBoolean.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/nullableCharBoolean.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("numberEqualsHashCodeToString.kt")
|
||||||
|
public void testNumberEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/numberEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("rangeTo.kt")
|
@TestMetadata("rangeTo.kt")
|
||||||
public void testRangeTo() throws Exception {
|
public void testRangeTo() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stringEqualsHashCodeToString.kt")
|
||||||
|
public void testStringEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/stringEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("substituteIntForGeneric.kt")
|
@TestMetadata("substituteIntForGeneric.kt")
|
||||||
public void testSubstituteIntForGeneric() throws Exception {
|
public void testSubstituteIntForGeneric() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
||||||
|
|||||||
+10
@@ -15006,11 +15006,21 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/primitiveTypes/nullableCharBoolean.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/nullableCharBoolean.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("numberEqualsHashCodeToString.kt")
|
||||||
|
public void testNumberEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/numberEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("rangeTo.kt")
|
@TestMetadata("rangeTo.kt")
|
||||||
public void testRangeTo() throws Exception {
|
public void testRangeTo() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/rangeTo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("stringEqualsHashCodeToString.kt")
|
||||||
|
public void testStringEqualsHashCodeToString() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/primitiveTypes/stringEqualsHashCodeToString.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("substituteIntForGeneric.kt")
|
@TestMetadata("substituteIntForGeneric.kt")
|
||||||
public void testSubstituteIntForGeneric() throws Exception {
|
public void testSubstituteIntForGeneric() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
runTest("compiler/testData/codegen/box/primitiveTypes/substituteIntForGeneric.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user