feat: add test data

This commit is contained in:
Jayme Bird 2022-09-02 15:08:47 +01:00 committed by Stanisław Barzowski
parent 6e180a9368
commit 5440cc833f
11 changed files with 38 additions and 1 deletions

View File

@ -1620,7 +1620,7 @@ func builtinParseInt(i *interpreter, x value) (value, error) {
} }
res, err := strconv.ParseInt(str.getGoString(), 10, 64) res, err := strconv.ParseInt(str.getGoString(), 10, 64)
if err != nil { if err != nil {
return nil, err return nil, i.Error(fmt.Sprintf("%s is not a base 10 integer", str.getGoString()))
} }
return makeValueNumber(float64(res)), nil return makeValueNumber(float64(res)), nil
} }

1
testdata/builtin_parseInt.golden vendored Normal file
View File

@ -0,0 +1 @@
123

1
testdata/builtin_parseInt.jsonnet vendored Normal file
View File

@ -0,0 +1 @@
std.parseInt("123")

1
testdata/builtin_parseInt2.golden vendored Normal file
View File

@ -0,0 +1 @@
-123

1
testdata/builtin_parseInt2.jsonnet vendored Normal file
View File

@ -0,0 +1 @@
std.parseInt("-123")

View File

@ -0,0 +1,10 @@
RUNTIME ERROR: hello is not a base 10 integer
-------------------------------------------------
testdata/builtin_parseInt_invalid:1:1-22 $
std.parseInt("hello")
-------------------------------------------------
During evaluation

View File

@ -0,0 +1 @@
std.parseInt("hello")

View File

@ -0,0 +1,10 @@
RUNTIME ERROR: 123.12 is not a base 10 integer
-------------------------------------------------
testdata/builtin_parseInt_invalid_decimal:1:1-23 $
std.parseInt("123.12")
-------------------------------------------------
During evaluation

View File

@ -0,0 +1 @@
std.parseInt("123.12")

View File

@ -0,0 +1,10 @@
RUNTIME ERROR: 7B316 is not a base 10 integer
-------------------------------------------------
testdata/builtin_parseInt_invalid_hexadecimal:1:1-22 $
std.parseInt("7B316")
-------------------------------------------------
During evaluation

View File

@ -0,0 +1 @@
std.parseInt("7B316")