Add spec tests for integer literals
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, binary-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [1] A sequence of binary digit symbols (0 or 1) prefixed by 0b or 0B is a binary integer literal.
|
||||
NUMBER: 1
|
||||
DESCRIPTION: Binary integer literals with the prefix only.
|
||||
*/
|
||||
|
||||
val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0b<!>
|
||||
val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0B<!>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Int
|
||||
public val value_2: kotlin.Int
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, binary-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one.
|
||||
NUMBER: 1
|
||||
DESCRIPTION: Binary integer literals with an underscore after the prefix.
|
||||
*/
|
||||
|
||||
val value_1 = <!ILLEGAL_UNDERSCORE!>0b_1110100000<!>
|
||||
val value_2 = <!ILLEGAL_UNDERSCORE!>0B_______11010000<!>
|
||||
val value_3 = <!ILLEGAL_UNDERSCORE!>0B_1_1_0_1_0_0_0_0<!>
|
||||
val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_<!>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Int = 928
|
||||
public val value_2: kotlin.Int = 208
|
||||
public val value_3: kotlin.Int = 208
|
||||
public val value_4: kotlin.Int
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, binary-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one.
|
||||
NUMBER: 2
|
||||
DESCRIPTION: Binary integer literals with an underscore in the first position (it's considered as identifiers).
|
||||
*/
|
||||
|
||||
val value_0 = <!UNRESOLVED_REFERENCE!>_____0b0_1_1_1_0_1<!>
|
||||
val value_1 = <!UNRESOLVED_REFERENCE!>_0B1_______1_______1_______0<!>
|
||||
val value_2 = <!UNRESOLVED_REFERENCE!>_0_0B1_0_1_1_1_0_1_1<!>
|
||||
val value_3 = <!UNRESOLVED_REFERENCE!>_0B000000000<!>
|
||||
val value_4 = <!UNRESOLVED_REFERENCE!>_0000000000b<!>
|
||||
val value_5 = <!UNRESOLVED_REFERENCE!>_0_1b<!>
|
||||
val value_6 = <!UNRESOLVED_REFERENCE!>____________0b<!>
|
||||
val value_7 = <!UNRESOLVED_REFERENCE!>_0_b_0<!>
|
||||
val value_8 = <!UNRESOLVED_REFERENCE!>_b_0<!>
|
||||
val value_9 = <!UNRESOLVED_REFERENCE!>_b<!>
|
||||
val value_10 = <!UNRESOLVED_REFERENCE!>_b_<!>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public val value_0: [ERROR : Type for _____0b0_1_1_1_0_1]
|
||||
public val value_1: [ERROR : Type for _0B1_______1_______1_______0]
|
||||
public val value_10: [ERROR : Type for _b_]
|
||||
public val value_2: [ERROR : Type for _0_0B1_0_1_1_1_0_1_1]
|
||||
public val value_3: [ERROR : Type for _0B000000000]
|
||||
public val value_4: [ERROR : Type for _0000000000b]
|
||||
public val value_5: [ERROR : Type for _0_1b]
|
||||
public val value_6: [ERROR : Type for ____________0b]
|
||||
public val value_7: [ERROR : Type for _0_b_0]
|
||||
public val value_8: [ERROR : Type for _b_0]
|
||||
public val value_9: [ERROR : Type for _b]
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, binary-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one.
|
||||
NUMBER: 3
|
||||
DESCRIPTION: Binary integer literals with an underscore in the last position.
|
||||
*/
|
||||
|
||||
val value_1 = <!ILLEGAL_UNDERSCORE!>0b0_1_1_0_1_1_____<!>
|
||||
val value_2 = <!ILLEGAL_UNDERSCORE!>0B1_______1_______0_______1_<!>
|
||||
val value_3 = <!ILLEGAL_UNDERSCORE!>0B000000000_<!>
|
||||
val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_<!>
|
||||
val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B______________<!>
|
||||
val value_6 = <!ILLEGAL_UNDERSCORE!>0B0_<!>
|
||||
val value_7 = <!ILLEGAL_UNDERSCORE!>0B10_<!>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Int = 27
|
||||
public val value_2: kotlin.Int = 13
|
||||
public val value_3: kotlin.Int = 0
|
||||
public val value_4: kotlin.Int
|
||||
public val value_5: kotlin.Int
|
||||
public val value_6: kotlin.Int = 0
|
||||
public val value_7: kotlin.Int = 2
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, decimal-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one.
|
||||
NUMBER: 1
|
||||
DESCRIPTION: Integer literals with an underscore in the last position.
|
||||
*/
|
||||
|
||||
val value_1 = <!ILLEGAL_UNDERSCORE!>1_<!>
|
||||
val value_2 = <!ILLEGAL_UNDERSCORE!>1_00000000000000000_<!>
|
||||
val value_3 = <!ILLEGAL_UNDERSCORE!>1_____________<!>
|
||||
val value_4 = <!ILLEGAL_UNDERSCORE!>9____________0_<!>
|
||||
val value_5 = <!ILLEGAL_UNDERSCORE!>1_______________________________________________________________________________________________________________________________________________________<!>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Int = 1
|
||||
public val value_2: kotlin.Long = 100000000000000000.toLong()
|
||||
public val value_3: kotlin.Int = 1
|
||||
public val value_4: kotlin.Int = 90
|
||||
public val value_5: kotlin.Int = 1
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, decimal-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one.
|
||||
NUMBER: 2
|
||||
DESCRIPTION: Integer literals with an underscore in the first position (it's considered as identifiers).
|
||||
*/
|
||||
|
||||
val value_1 = <!UNRESOLVED_REFERENCE!>_5678_90<!>
|
||||
val value_2 = <!UNRESOLVED_REFERENCE!>_2_3_4_5_6_7_8_9_<!>
|
||||
val value_3 = <!UNRESOLVED_REFERENCE!>_____________0000<!>
|
||||
val value_4 = <!UNRESOLVED_REFERENCE!>_______________________________________________________________________________________________________________________________________________________0<!>
|
||||
val value_5 = <!UNRESOLVED_REFERENCE!>____________________________________________________<!>
|
||||
val value_6 = <!UNRESOLVED_REFERENCE!>_<!>
|
||||
val value_7 = <!UNRESOLVED_REFERENCE!>_0_<!>
|
||||
val value_8 = <!UNRESOLVED_REFERENCE!>_9_<!>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public val value_1: [ERROR : Type for _5678_90]
|
||||
public val value_2: [ERROR : Type for _2_3_4_5_6_7_8_9_]
|
||||
public val value_3: [ERROR : Type for _____________0000]
|
||||
public val value_4: [ERROR : Type for _______________________________________________________________________________________________________________________________________________________0]
|
||||
public val value_5: [ERROR : Type for ____________________________________________________]
|
||||
public val value_6: [ERROR : Type for _]
|
||||
public val value_7: [ERROR : Type for _0_]
|
||||
public val value_8: [ERROR : Type for _9_]
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [1] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal.
|
||||
NUMBER: 1
|
||||
DESCRIPTION: Hexadecimal integer literals with the prefix only.
|
||||
*/
|
||||
|
||||
val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0x<!>
|
||||
val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0X<!>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Int
|
||||
public val value_2: kotlin.Int
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one.
|
||||
NUMBER: 1
|
||||
DESCRIPTION: Hexadecimal integer literals with an underscore after the prefix.
|
||||
*/
|
||||
|
||||
val value_1 = <!ILLEGAL_UNDERSCORE!>0x_1234567890<!>
|
||||
val value_2 = <!ILLEGAL_UNDERSCORE!>0X_______23456789<!>
|
||||
val value_3 = <!ILLEGAL_UNDERSCORE!>0X_2_3_4_5_6_7_8_9<!>
|
||||
val value_4 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_<!>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Long = 78187493520.toLong()
|
||||
public val value_2: kotlin.Int = 591751049
|
||||
public val value_3: kotlin.Int = 591751049
|
||||
public val value_4: kotlin.Int
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] Digits may be separated by an underscore symbol, but no underscore can be placed before the first digit or after the last one.
|
||||
NUMBER: 2
|
||||
DESCRIPTION: Hexadecimal integer literals with an underscore in the first position (it's considered as identifiers).
|
||||
*/
|
||||
|
||||
val value_1 = <!UNRESOLVED_REFERENCE!>_____0x3_4_5_6_7_8<!>
|
||||
val value_2 = <!UNRESOLVED_REFERENCE!>_0X4_______5_______6_______7<!>
|
||||
val value_3 = <!UNRESOLVED_REFERENCE!>_0_0X4_3_4_5_6_7_8_9<!>
|
||||
val value_4 = <!UNRESOLVED_REFERENCE!>_0X000000000<!>
|
||||
val value_5 = <!UNRESOLVED_REFERENCE!>_0000000000x<!>
|
||||
val value_6 = <!UNRESOLVED_REFERENCE!>_0_9x<!>
|
||||
val value_7 = <!UNRESOLVED_REFERENCE!>____________0x<!>
|
||||
val value_8 = <!UNRESOLVED_REFERENCE!>_0_x_0<!>
|
||||
val value_9 = <!UNRESOLVED_REFERENCE!>_x_0<!>
|
||||
val value_10 = <!UNRESOLVED_REFERENCE!>_x<!>
|
||||
val value_11 = <!UNRESOLVED_REFERENCE!>_x_<!>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public val value_1: [ERROR : Type for _____0x3_4_5_6_7_8]
|
||||
public val value_10: [ERROR : Type for _x]
|
||||
public val value_11: [ERROR : Type for _x_]
|
||||
public val value_2: [ERROR : Type for _0X4_______5_______6_______7]
|
||||
public val value_3: [ERROR : Type for _0_0X4_3_4_5_6_7_8_9]
|
||||
public val value_4: [ERROR : Type for _0X000000000]
|
||||
public val value_5: [ERROR : Type for _0000000000x]
|
||||
public val value_6: [ERROR : Type for _0_9x]
|
||||
public val value_7: [ERROR : Type for ____________0x]
|
||||
public val value_8: [ERROR : Type for _0_x_0]
|
||||
public val value_9: [ERROR : Type for _x_0]
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, hexadecimal-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] A sequence of hexadecimal digit symbols (0 through 9, a through f, A through F) prefixed by 0x or 0X is a hexadecimal integer literal.
|
||||
NUMBER: 3
|
||||
DESCRIPTION: Hexadecimal integer literals with an underscore in the last position.
|
||||
*/
|
||||
|
||||
val value_1 = <!ILLEGAL_UNDERSCORE!>0x3_4_5_6_7_8_____<!>
|
||||
val value_2 = <!ILLEGAL_UNDERSCORE!>0X4_______5_______6_______7_<!>
|
||||
val value_3 = <!ILLEGAL_UNDERSCORE!>0X000000000_<!>
|
||||
val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_<!>
|
||||
val value_6 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0X______________<!>
|
||||
val value_7 = <!ILLEGAL_UNDERSCORE!>0X0_<!>
|
||||
val value_8 = <!ILLEGAL_UNDERSCORE!>0X10_<!>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Int = 3430008
|
||||
public val value_2: kotlin.Int = 17767
|
||||
public val value_3: kotlin.Int = 0
|
||||
public val value_5: kotlin.Int
|
||||
public val value_6: kotlin.Int
|
||||
public val value_7: kotlin.Int = 0
|
||||
public val value_8: kotlin.Int = 16
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L).
|
||||
NUMBER: 1
|
||||
DESCRIPTION: Binary and hexadecimal integer literals with a long literal mark only.
|
||||
*/
|
||||
|
||||
val value_1 = <!INT_LITERAL_OUT_OF_RANGE!>0bl<!>
|
||||
val value_2 = <!INT_LITERAL_OUT_OF_RANGE!>0BL<!>
|
||||
val value_3 = <!INT_LITERAL_OUT_OF_RANGE!>0Xl<!>
|
||||
val value_4 = <!INT_LITERAL_OUT_OF_RANGE!>0xL<!>
|
||||
|
||||
val value_5 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0b_l<!>
|
||||
val value_6 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B_L<!>
|
||||
val value_7 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0X____l<!>
|
||||
val value_8 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0x_L<!>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Int
|
||||
public val value_2: kotlin.Int
|
||||
public val value_3: kotlin.Int
|
||||
public val value_4: kotlin.Int
|
||||
public val value_5: kotlin.Int
|
||||
public val value_6: kotlin.Int
|
||||
public val value_7: kotlin.Int
|
||||
public val value_8: kotlin.Int
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L).
|
||||
NUMBER: 2
|
||||
DESCRIPTION: Various integer literals with a not allowed underscore before the long literal mark.
|
||||
*/
|
||||
|
||||
val value_1 = <!ILLEGAL_UNDERSCORE!>0b0_<!WRONG_LONG_SUFFIX!>l<!><!>
|
||||
val value_2 = <!ILLEGAL_UNDERSCORE, INT_LITERAL_OUT_OF_RANGE!>0B12_L<!>
|
||||
val value_3 = <!ILLEGAL_UNDERSCORE!>0X234_<!WRONG_LONG_SUFFIX!>l<!><!>
|
||||
val value_4 = <!ILLEGAL_UNDERSCORE!>0x3567_L<!>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Long = 0.toLong()
|
||||
public val value_2: kotlin.Int
|
||||
public val value_3: kotlin.Long = 564.toLong()
|
||||
public val value_4: kotlin.Long = 13671.toLong()
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [1] Any of the decimal, hexadecimal or binary literals may be suffixed by the long literal mark (symbol L).
|
||||
NUMBER: 3
|
||||
DESCRIPTION: Various integer literals with not allowed long literal mark in lower case.
|
||||
*/
|
||||
|
||||
val value_1 = 0<!WRONG_LONG_SUFFIX!>l<!>
|
||||
val value_2 = 1000000000000000<!WRONG_LONG_SUFFIX!>l<!>
|
||||
val value_3 = 0X0<!WRONG_LONG_SUFFIX!>l<!>
|
||||
val value_4 = 0b101<!WRONG_LONG_SUFFIX!>l<!>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public val value_1: kotlin.Long = 0.toLong()
|
||||
public val value_2: kotlin.Long = 1000000000000000.toLong()
|
||||
public val value_3: kotlin.Long = 0.toLong()
|
||||
public val value_4: kotlin.Long = 5.toLong()
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 1
|
||||
DESCRIPTION: Various integer literals with not allowed long literal mark in lower case (type checking).
|
||||
*/
|
||||
|
||||
fun case_1() {
|
||||
0<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() }
|
||||
10000000000000<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() }
|
||||
0X000Af10cD<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() }
|
||||
0x0_0<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() }
|
||||
0b100_000_111_111<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() }
|
||||
0b0<!WRONG_LONG_SUFFIX!>l<!> checkType { _<Long>() }
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 2
|
||||
DESCRIPTION: Type checking (comparison with invalid types) of various integer literals with long literal mark.
|
||||
*/
|
||||
|
||||
fun case_1() {
|
||||
0L checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
1000000L checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
0XAf10cDL checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
0x0_0L checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
0b100_000_111_111L checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
0b0L checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
|
||||
checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>0L<!>)
|
||||
checkSubtype<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1000000L<!>)
|
||||
checkSubtype<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>0XAf10cDL<!>)
|
||||
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>0x0_0L<!>)
|
||||
checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>0b100_000_111_111L<!>)
|
||||
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>0b0L<!>)
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 3
|
||||
DESCRIPTION: Type checking (comparison with invalid types) of various integer literals.
|
||||
*/
|
||||
|
||||
fun case_1() {
|
||||
0 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
0 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
0 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
127 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
127 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
127 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>128<!>)
|
||||
128 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
128 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
128 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
-128 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
-128 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
-128 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!TYPE_MISMATCH!>-129<!>)
|
||||
-129 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
-129 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
-129 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32767<!>)
|
||||
32767 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
32767 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
32767 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32768<!>)
|
||||
checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32768<!>)
|
||||
32768 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
32768 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
32768 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!TYPE_MISMATCH!>-32768<!>)
|
||||
-32768 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
-32768 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
-32768 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!TYPE_MISMATCH!>-32769<!>)
|
||||
checkSubtype<Short>(<!TYPE_MISMATCH!>-32769<!>)
|
||||
-32769 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
-32769 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
-32769 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483647<!>)
|
||||
checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483647<!>)
|
||||
2147483647 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
2147483647 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
2147483647 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483648<!>)
|
||||
checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483648<!>)
|
||||
checkSubtype<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483648<!>)
|
||||
2147483648 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
2147483648 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
2147483648 checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
|
||||
checkSubtype<Byte>(<!TYPE_MISMATCH!>-2147483648<!>)
|
||||
checkSubtype<Short>(<!TYPE_MISMATCH!>-2147483648<!>)
|
||||
-2147483648 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
-2147483648 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
-2147483648 checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Byte>(<!TYPE_MISMATCH!>-2147483649<!>)
|
||||
checkSubtype<Short>(<!TYPE_MISMATCH!>-2147483649<!>)
|
||||
checkSubtype<Int>(<!TYPE_MISMATCH!>-2147483649<!>)
|
||||
-2147483649 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
-2147483649 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
-2147483649 checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
|
||||
checkSubtype<Byte>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
|
||||
checkSubtype<Short>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
|
||||
checkSubtype<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
|
||||
9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
|
||||
checkSubtype<Byte>(<!TYPE_MISMATCH!>-9223372036854775807<!>)
|
||||
checkSubtype<Short>(<!TYPE_MISMATCH!>-9223372036854775807<!>)
|
||||
checkSubtype<Int>(<!TYPE_MISMATCH!>-9223372036854775807<!>)
|
||||
-9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
-9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
-9223372036854775807 checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
|
||||
checkSubtype<Byte>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!><!>)
|
||||
checkSubtype<Short>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!><!>)
|
||||
checkSubtype<Int>(-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!>)
|
||||
checkSubtype<Long>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!><!>)
|
||||
-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!> checkType { <!TYPE_MISMATCH!>_<!><Byte>() }
|
||||
-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!> checkType { <!TYPE_MISMATCH!>_<!><Short>() }
|
||||
-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!> checkType { _<Int>() }
|
||||
-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 4
|
||||
DESCRIPTION: Type checking (comparison with invalid types) of too a big integers.
|
||||
*/
|
||||
|
||||
fun case_1() {
|
||||
checkSubtype<Long>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!><!>)
|
||||
-<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Long>(<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!>)
|
||||
<!INT_LITERAL_OUT_OF_RANGE!>9223372036854775808L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Long>(<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000L<!>)
|
||||
<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Long>(<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000l<!>)
|
||||
<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000l<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Long>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000L<!><!>)
|
||||
-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000L<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
|
||||
checkSubtype<Long>(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000l<!><!>)
|
||||
-<!INT_LITERAL_OUT_OF_RANGE!>100000000000000000000000000000000l<!> checkType { <!TYPE_MISMATCH!>_<!><Long>() }
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 5
|
||||
DESCRIPTION: Check of integer type selection depends on the context (incopatible types).
|
||||
*/
|
||||
|
||||
// FILE: functions.kt
|
||||
|
||||
package functions
|
||||
|
||||
fun f1(x1: Byte) = x1
|
||||
|
||||
fun f2(x1: Short) = x1
|
||||
|
||||
fun f3(x1: Int) = x1
|
||||
|
||||
fun f4(x1: Long) = x1
|
||||
|
||||
// FILE: usages.kt
|
||||
|
||||
import functions.*
|
||||
|
||||
fun case_1() {
|
||||
f1(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>128<!>)
|
||||
f1(<!TYPE_MISMATCH!>-129<!>)
|
||||
f1(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32767<!>)
|
||||
f1(<!TYPE_MISMATCH!>-32768<!>)
|
||||
f1(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483647<!>)
|
||||
f1(<!TYPE_MISMATCH!>-2147483648<!>)
|
||||
f1(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
|
||||
f1(<!TYPE_MISMATCH!>-9223372036854775807<!>)
|
||||
f1(<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
|
||||
f1(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!><!>)
|
||||
}
|
||||
|
||||
fun case_2() {
|
||||
f2(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>32768<!>)
|
||||
f2(<!TYPE_MISMATCH!>-32769<!>)
|
||||
f2(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>2147483647<!>)
|
||||
f2(<!TYPE_MISMATCH!>-2147483648<!>)
|
||||
f2(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
|
||||
f2(<!TYPE_MISMATCH!>-9223372036854775807<!>)
|
||||
f2(<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
|
||||
f2(<!TYPE_MISMATCH!>-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!><!>)
|
||||
}
|
||||
|
||||
fun case_3() {
|
||||
f3(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>9223372036854775807<!>)
|
||||
f3(<!TYPE_MISMATCH!>-9223372036854775807<!>)
|
||||
f3(<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
|
||||
f3(-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
|
||||
}
|
||||
|
||||
fun case_4() {
|
||||
f3(<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
|
||||
f3(-<!INT_LITERAL_OUT_OF_RANGE!>1000000000000000000000000000000000000000000000000<!>)
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 1
|
||||
DESCRIPTION: Type checking of various integer literals with long literal mark.
|
||||
*/
|
||||
|
||||
fun case_1() {
|
||||
0L checkType { _<Long>() }
|
||||
10000000000000L checkType { _<Long>() }
|
||||
0X000Af10cDL checkType { _<Long>() }
|
||||
0x0_0L checkType { _<Long>() }
|
||||
0b100_000_111_111L checkType { _<Long>() }
|
||||
0b0L checkType { _<Long>() }
|
||||
}
|
||||
|
||||
fun case_2() {
|
||||
9223372036854775807L checkType { _<Long>() }
|
||||
-9223372036854775807L checkType { _<Long>() }
|
||||
|
||||
0X7FFFFFFFFFFFFFFFL checkType { _<Long>() }
|
||||
-0x7FFFFFFFFFFFFFFFL checkType { _<Long>() }
|
||||
|
||||
0b111111111111111111111111111111111111111111111111111111111111111L checkType { _<Long>() }
|
||||
-0B111111111111111111111111111111111111111111111111111111111111111L checkType { _<Long>() }
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 2
|
||||
DESCRIPTION: Type checking of decimal integer literals.
|
||||
*/
|
||||
|
||||
fun case_1() {
|
||||
0 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0)
|
||||
checkSubtype<Short>(0)
|
||||
checkSubtype<Byte>(0)
|
||||
checkSubtype<Long>(0)
|
||||
|
||||
127 checkType { _<Int>() }
|
||||
checkSubtype<Int>(127)
|
||||
checkSubtype<Short>(127)
|
||||
checkSubtype<Byte>(127)
|
||||
checkSubtype<Long>(127)
|
||||
|
||||
128 checkType { _<Int>() }
|
||||
checkSubtype<Int>(128)
|
||||
checkSubtype<Short>(128)
|
||||
checkSubtype<Long>(128)
|
||||
|
||||
-128 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-128)
|
||||
checkSubtype<Short>(-128)
|
||||
checkSubtype<Byte>(-128)
|
||||
checkSubtype<Long>(-128)
|
||||
|
||||
-129 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-129)
|
||||
checkSubtype<Short>(-129)
|
||||
checkSubtype<Long>(-129)
|
||||
|
||||
32767 checkType { _<Int>() }
|
||||
checkSubtype<Int>(32767)
|
||||
checkSubtype<Short>(32767)
|
||||
checkSubtype<Long>(32767)
|
||||
|
||||
32768 checkType { _<Int>() }
|
||||
checkSubtype<Int>(32768)
|
||||
checkSubtype<Long>(32768)
|
||||
|
||||
-32768 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-32768)
|
||||
checkSubtype<Short>(-32768)
|
||||
checkSubtype<Long>(-32768)
|
||||
|
||||
-32769 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-32769)
|
||||
checkSubtype<Long>(-32769)
|
||||
|
||||
2147483647 checkType { _<Int>() }
|
||||
checkSubtype<Int>(2147483647)
|
||||
checkSubtype<Long>(2147483647)
|
||||
|
||||
2147483648 checkType { _<Long>() }
|
||||
checkSubtype<Long>(2147483648)
|
||||
|
||||
-2147483648 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-2147483648)
|
||||
checkSubtype<Long>(-2147483648)
|
||||
|
||||
-2147483649 checkType { _<Long>() }
|
||||
checkSubtype<Long>(-2147483649)
|
||||
|
||||
9223372036854775807 checkType { _<Long>() }
|
||||
checkSubtype<Long>(9223372036854775807)
|
||||
|
||||
-9223372036854775807 checkType { _<Long>() }
|
||||
checkSubtype<Long>(-9223372036854775807)
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 3
|
||||
DESCRIPTION: Type checking of hexadecimal integer literals.
|
||||
*/
|
||||
|
||||
fun case_1() {
|
||||
0x0 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0x0)
|
||||
checkSubtype<Short>(0x0)
|
||||
checkSubtype<Byte>(0x0)
|
||||
checkSubtype<Long>(0x0)
|
||||
|
||||
0x7F checkType { _<Int>() }
|
||||
checkSubtype<Int>(0x7F)
|
||||
checkSubtype<Short>(0x7F)
|
||||
checkSubtype<Byte>(0x7F)
|
||||
checkSubtype<Long>(0x7F)
|
||||
|
||||
0X80 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0X80)
|
||||
checkSubtype<Short>(0X80)
|
||||
checkSubtype<Long>(0X80)
|
||||
|
||||
-0X80 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0X80)
|
||||
checkSubtype<Short>(-0X80)
|
||||
checkSubtype<Byte>(-0X80)
|
||||
checkSubtype<Long>(-0X80)
|
||||
|
||||
-0x81 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0x81)
|
||||
checkSubtype<Short>(-0x81)
|
||||
checkSubtype<Long>(-0x81)
|
||||
|
||||
0x7FFF checkType { _<Int>() }
|
||||
checkSubtype<Int>(0x7FFF)
|
||||
checkSubtype<Short>(0x7FFF)
|
||||
checkSubtype<Long>(0x7FFF)
|
||||
|
||||
0x8000 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0x8000)
|
||||
checkSubtype<Long>(0x8000)
|
||||
|
||||
-0x8000 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0x8000)
|
||||
checkSubtype<Short>(-0x8000)
|
||||
checkSubtype<Long>(-0x8000)
|
||||
|
||||
-0X8001 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0X8001)
|
||||
checkSubtype<Long>(-0X8001)
|
||||
|
||||
0x7FFFFFFF checkType { _<Int>() }
|
||||
checkSubtype<Int>(0x7FFFFFFF)
|
||||
checkSubtype<Long>(0x7FFFFFFF)
|
||||
|
||||
0x80000000 checkType { _<Long>() }
|
||||
checkSubtype<Long>(0x80000000)
|
||||
|
||||
-0x80000000 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0x80000000)
|
||||
checkSubtype<Long>(-0x80000000)
|
||||
|
||||
-0x80000001 checkType { _<Long>() }
|
||||
checkSubtype<Long>(-0x80000001)
|
||||
|
||||
0X7FFFFFFFFFFFFFFF checkType { _<Long>() }
|
||||
checkSubtype<Long>(0X7FFFFFFFFFFFFFFF)
|
||||
|
||||
-0X7FFFFFFFFFFFFFFF checkType { _<Long>() }
|
||||
checkSubtype<Long>(-0X7FFFFFFFFFFFFFFF)
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 4
|
||||
DESCRIPTION: Type checking of binary integer literals.
|
||||
*/
|
||||
|
||||
fun case_1() {
|
||||
0b0 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0b0)
|
||||
checkSubtype<Short>(0b0)
|
||||
checkSubtype<Byte>(0b0)
|
||||
checkSubtype<Long>(0b0)
|
||||
|
||||
0B1111111 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0B1111111)
|
||||
checkSubtype<Short>(0B1111111)
|
||||
checkSubtype<Byte>(0B1111111)
|
||||
checkSubtype<Long>(0B1111111)
|
||||
|
||||
0b10000000 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0b10000000)
|
||||
checkSubtype<Short>(0b10000000)
|
||||
checkSubtype<Long>(0b10000000)
|
||||
|
||||
-0B10000000 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0B10000000)
|
||||
checkSubtype<Short>(-0B10000000)
|
||||
checkSubtype<Byte>(-0B10000000)
|
||||
checkSubtype<Long>(-0B10000000)
|
||||
|
||||
-0b10000001 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0b10000001)
|
||||
checkSubtype<Short>(-0b10000001)
|
||||
checkSubtype<Long>(-0b10000001)
|
||||
|
||||
0B111111111111111 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0B111111111111111)
|
||||
checkSubtype<Short>(0B111111111111111)
|
||||
checkSubtype<Long>(0B111111111111111)
|
||||
|
||||
0b1000000000000000 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0b1000000000000000)
|
||||
checkSubtype<Long>(0b1000000000000000)
|
||||
|
||||
-0b1000000000000000 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0b1000000000000000)
|
||||
checkSubtype<Short>(-0b1000000000000000)
|
||||
checkSubtype<Long>(-0b1000000000000000)
|
||||
|
||||
-0B1000000000000001 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0B1000000000000001)
|
||||
checkSubtype<Long>(-0B1000000000000001)
|
||||
|
||||
0b1111111111111111111111111111111 checkType { _<Int>() }
|
||||
checkSubtype<Int>(0b1111111111111111111111111111111)
|
||||
checkSubtype<Long>(0b1111111111111111111111111111111)
|
||||
|
||||
0B10000000000000000000000000000000 checkType { _<Long>() }
|
||||
checkSubtype<Long>(0B10000000000000000000000000000000)
|
||||
|
||||
-0B10000000000000000000000000000000 checkType { _<Int>() }
|
||||
checkSubtype<Int>(-0B10000000000000000000000000000000)
|
||||
checkSubtype<Long>(-0B10000000000000000000000000000000)
|
||||
|
||||
-0b10000000000000000000000000000001 checkType { _<Long>() }
|
||||
checkSubtype<Long>(-0b10000000000000000000000000000001)
|
||||
|
||||
0b111111111111111111111111111111111111111111111111111111111111111 checkType { _<Long>() }
|
||||
checkSubtype<Long>(0b111111111111111111111111111111111111111111111111111111111111111)
|
||||
|
||||
-0B111111111111111111111111111111111111111111111111111111111111111 checkType { _<Long>() }
|
||||
checkSubtype<Long>(-0B111111111111111111111111111111111111111111111111111111111111111)
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
|
||||
SECTIONS: constant-literals, integer-literals, long-integer-literals
|
||||
PARAGRAPH: 1
|
||||
SENTENCE: [2] An integer literal with the long literal mark has type kotlin.Long; an integer literal without it has one of the types kotlin.Int/kotlin.Short/kotlin.Byte (the selected type is dependent on the context), if its value is in range of the corresponding type, or type kotlin.Long otherwise.
|
||||
NUMBER: 5
|
||||
DESCRIPTION: Check of integer type selection depends on the context.
|
||||
*/
|
||||
|
||||
// FILE: functions.kt
|
||||
|
||||
package functions
|
||||
|
||||
fun f1(x1: Byte, x2: Short, x3: Int, x4: Long) = x1 + x2 + x3 + x4
|
||||
|
||||
fun f2(x1: Short, x2: Int, x3: Long) = x1 + x2 + x3
|
||||
|
||||
fun f3(x1: Int, x2: Long) = x1 + x2
|
||||
|
||||
fun f4(x1: Long) = x1
|
||||
|
||||
// FILE: usages.kt
|
||||
|
||||
import functions.*
|
||||
|
||||
fun case_1() {
|
||||
f1(0, 0, 0, 0)
|
||||
f1(127, 127, 127, 127)
|
||||
f1(-128, -128, -128, -128)
|
||||
}
|
||||
|
||||
fun case_2() {
|
||||
f2(128, 128, 128)
|
||||
f2(-129, -129, -129)
|
||||
f2(32767, 32767, 32767)
|
||||
f2(-32768, -32768, -32768)
|
||||
}
|
||||
|
||||
fun case_3() {
|
||||
f3(32768, 32768)
|
||||
f3(-32769, -32769)
|
||||
f3(2147483647, 2147483647)
|
||||
f3(-2147483648, -2147483648)
|
||||
}
|
||||
|
||||
fun case_4() {
|
||||
f4(2147483648)
|
||||
f4(-2147483649)
|
||||
f4(9223372036854775807)
|
||||
f4(-9223372036854775807)
|
||||
}
|
||||
Reference in New Issue
Block a user