Skip to content

Commit 939f970

Browse files
committed
Update tests for golang
1 parent 0887553 commit 939f970

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

test_cmd/help.golden.stdout.golang

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
Jsonnet commandline interpreter v0.12.1
22

3-
General commandline:
4-
jsonnet [<cmd>] {<option>} { <filename> }
5-
Note: <cmd> defaults to "eval"
3+
jsonnet {<option>} <filename>
64

7-
The eval command:
8-
jsonnet eval {<option>} <filename>
9-
Note: Only one filename is supported
10-
11-
Available eval options:
5+
Available options:
126
-h / --help This message
137
-e / --exec Treat filename as code
14-
-J / --jpath <dir> Specify an additional library search dir
8+
-J / --jpath <dir> Specify an additional library search dir (right-most wins)
159
-o / --output-file <file> Write to the output file rather than stdout
1610
-m / --multi <dir> Write multiple files to the directory, list files on stdout
1711
-c / --create-output-dirs Automatically creates all parent directories for files
@@ -34,9 +28,12 @@ Provide the value as a string:
3428
Provide a value as Jsonnet code:
3529
--tla-code <var>[=<code>] If <code> is omitted, get from environment var <var>
3630
--tla-code-file <var>=<file> Read the code from the file
37-
38-
The fmt command:
39-
jsonnet fmt is currently not available in the Go implementation
31+
Environment variables:
32+
JSONNET_PATH is a colon (semicolon on Windows) separated list of directories added
33+
in reverse order before the paths specified by --jpath (i.e. left-most wins)
34+
E.g. JSONNET_PATH=a:b jsonnet -J c -J d is equivalent to:
35+
JSONNET_PATH=d:c:a:b jsonnet
36+
jsonnet -J b -J a -J c -J d
4037

4138
In all cases:
4239
<filename> can be - (stdin)

test_cmd/no_args.golden.stderr.golang

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@ ERROR: must give filename
22

33
Jsonnet commandline interpreter v0.12.1
44

5-
General commandline:
6-
jsonnet [<cmd>] {<option>} { <filename> }
7-
Note: <cmd> defaults to "eval"
5+
jsonnet {<option>} <filename>
86

9-
The eval command:
10-
jsonnet eval {<option>} <filename>
11-
Note: Only one filename is supported
12-
13-
Available eval options:
7+
Available options:
148
-h / --help This message
159
-e / --exec Treat filename as code
16-
-J / --jpath <dir> Specify an additional library search dir
10+
-J / --jpath <dir> Specify an additional library search dir (right-most wins)
1711
-o / --output-file <file> Write to the output file rather than stdout
1812
-m / --multi <dir> Write multiple files to the directory, list files on stdout
1913
-c / --create-output-dirs Automatically creates all parent directories for files
@@ -36,9 +30,12 @@ Provide the value as a string:
3630
Provide a value as Jsonnet code:
3731
--tla-code <var>[=<code>] If <code> is omitted, get from environment var <var>
3832
--tla-code-file <var>=<file> Read the code from the file
39-
40-
The fmt command:
41-
jsonnet fmt is currently not available in the Go implementation
33+
Environment variables:
34+
JSONNET_PATH is a colon (semicolon on Windows) separated list of directories added
35+
in reverse order before the paths specified by --jpath (i.e. left-most wins)
36+
E.g. JSONNET_PATH=a:b jsonnet -J c -J d is equivalent to:
37+
JSONNET_PATH=d:c:a:b jsonnet
38+
jsonnet -J b -J a -J c -J d
4239

4340
In all cases:
4441
<filename> can be - (stdin)

test_cmd/run_cmd_tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ do_test "jsonnet_path1" 0 -e 'importstr "shared.txt"'
109109
export JSONNET_PATH=lib2:lib1
110110
do_test "jsonnet_path2" 0 -e 'importstr "shared.txt"'
111111

112+
if [ -z "$DISABLE_FMT_TESTS" ]; then
113+
112114
do_fmt_test "fmt_no_args" 1
113115
do_fmt_test "fmt_help" 0 --help
114116
do_fmt_test "fmt_version1" 0 -v
@@ -127,6 +129,8 @@ if do_fmt_test "fmt_out" 0 -e "{ a: 1, b: 2, c: 3 }" -o "out/fmt_out/custom_outp
127129
fi
128130
do_fmt_test "fmt_double_dash" 0 -e -- -1
129131

132+
fi
133+
130134

131135
popd
132136

test_suite/format.jsonnet

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ std.assertEqual(std.format('thing-%#-8.4X', [910.3]), 'thing-0X038E ') &&
135135
// e
136136
std.assertEqual(std.format('%e', [910]), '9.100000e+02') &&
137137
std.assertEqual(std.format('%e', [0]), '0.000000e+00') &&
138-
std.assertEqual(std.format('%e', [3.94066e-324]), '5.000000e-324') &&
139138
std.assertEqual(std.format('%.0le', [910]), '9e+02') &&
140139
std.assertEqual(std.format('%.0le', [0]), '0e+00') &&
141140
std.assertEqual(std.format('%#e', [-910]), '-9.100000e+02') &&
@@ -151,6 +150,10 @@ std.assertEqual(std.format('%-16.4e', [910.3]), '9.1030e+02 ') &&
151150
std.assertEqual(std.format('%#.0e', [910.3]), '9.e+02') &&
152151
std.assertEqual(std.format('%#.0e', [900]), '9.e+02') &&
153152
std.assertEqual(std.format('%.3e', [1000000001]), '1.000e+09') &&
153+
// For very small numbers, Go and C++ differ in the accuracy of log().
154+
// The following test makes sure that we don't at least have a runtime error
155+
// while calculating it.
156+
std.assertEqual(std.type(std.format('%e', [3.94066e-324])), 'string') &&
154157

155158
// E
156159
std.assertEqual(std.format('%E', [910]), '9.100000E+02') &&

0 commit comments

Comments
 (0)