mirror of
https://github.com/apple/pkl.git
synced 2026-05-03 13:44:26 +02:00
Allow to toInt() to parse a string including "__" (#578)
Fix the issue where String#toInt() cannot parse a Int string including sequence of "_" like "1_2__3___".
This commit is contained in:
@@ -225,6 +225,8 @@ examples {
|
||||
["toInt()"] {
|
||||
"123".toInt()
|
||||
"-123".toInt()
|
||||
"1_2__3___".toInt()
|
||||
"-1_2__3___".toInt()
|
||||
"0".toInt()
|
||||
"-0".toInt()
|
||||
module.catch(() -> "1.2".toInt())
|
||||
@@ -236,6 +238,8 @@ examples {
|
||||
["toIntOrNull()"] {
|
||||
"123".toIntOrNull()
|
||||
"-123".toIntOrNull()
|
||||
"1_2__3___".toInt()
|
||||
"-1_2__3___".toInt()
|
||||
"0".toIntOrNull()
|
||||
"-0".toIntOrNull()
|
||||
"1.2".toIntOrNull()
|
||||
@@ -445,7 +449,7 @@ examples {
|
||||
"".sha256
|
||||
quickBrownFox.sha256
|
||||
}
|
||||
|
||||
|
||||
["sha256Int"] {
|
||||
"".sha256Int
|
||||
quickBrownFox.sha256Int
|
||||
@@ -460,7 +464,7 @@ examples {
|
||||
"".base64
|
||||
quickBrownFox.base64
|
||||
}
|
||||
|
||||
|
||||
["base64Decoded"] {
|
||||
module.catch(() -> "~~~".base64Decoded)
|
||||
}
|
||||
|
||||
@@ -181,6 +181,8 @@ examples {
|
||||
List(97, 98, 99, 100, 101, 102, 103)
|
||||
}
|
||||
["toInt()"] {
|
||||
123
|
||||
-123
|
||||
123
|
||||
-123
|
||||
0
|
||||
@@ -191,6 +193,8 @@ examples {
|
||||
"Cannot parse string as `Int`. String: \"abc\""
|
||||
}
|
||||
["toIntOrNull()"] {
|
||||
123
|
||||
-123
|
||||
123
|
||||
-123
|
||||
0
|
||||
|
||||
Reference in New Issue
Block a user