File tree Expand file tree Collapse file tree 4 files changed +38
-2
lines changed Expand file tree Collapse file tree 4 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ libjsonnet++.so
19
19
libjsonnet++.so. *
20
20
libjsonnet_test_file
21
21
libjsonnet_test_snippet
22
+ libjsonnet_test_locale
22
23
** /core. *
23
24
** /vgcore
24
25
** /vgcore. *
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ install: bins libs
133
133
134
134
all : $(ALL )
135
135
136
- test : jsonnet jsonnetfmt libjsonnet.so libjsonnet_test_snippet libjsonnet_test_file
136
+ test : jsonnet jsonnetfmt libjsonnet.so libjsonnet_test_snippet libjsonnet_test_file libjsonnet_test_locale
137
137
./tests.sh
138
138
139
139
reformat :
@@ -146,7 +146,8 @@ MAKEDEPEND_SRCS = \
146
146
cmd/jsonnet.cpp \
147
147
cmd/jsonnetfmt.cpp \
148
148
core/libjsonnet_test_snippet.c \
149
- core/libjsonnet_test_file.c
149
+ core/libjsonnet_test_file.c \
150
+ core/libjsonnet_test_locale.cpp
150
151
151
152
depend : core/std.jsonnet.h
152
153
rm -f Makefile.depend
@@ -196,6 +197,14 @@ LIBJSONNET_TEST_FILE_SRCS = \
196
197
libjsonnet_test_file : $(LIBJSONNET_TEST_FILE_SRCS )
197
198
$(CC ) $(CFLAGS ) $(LDFLAGS ) $< -L. -ljsonnet -o $@
198
199
200
+ LIBJSONNET_TEST_LOCALE_SRCS = \
201
+ core/libjsonnet_test_locale.cpp \
202
+ libjsonnet++.so \
203
+ include/libjsonnet++.h
204
+
205
+ libjsonnet_test_locale : $(LIBJSONNET_TEST_LOCALE_SRCS )
206
+ $(CXX ) $(CXXFLAGS ) $(LDFLAGS ) $< -L. -ljsonnet++ -o $@
207
+
199
208
# Encode standard library for embedding in C
200
209
core/% .jsonnet.h : stdlib/% .jsonnet
201
210
(( $(OD) - v - Anone - t u1 $< \
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < locale>
3
+ #include < cassert>
4
+ #include < libjsonnet++.h>
5
+
6
+ // Regression test for the follwing issue: https://github.com/google/jsonnet/issues/722
7
+
8
+ int main () {
9
+ std::string templatedJSONString { " 2000" };
10
+ std::locale glocale (" en_US.UTF-8" );
11
+ std::locale::global (glocale);
12
+
13
+ jsonnet::Jsonnet jsonnet {};
14
+ jsonnet.init ();
15
+
16
+ std::string expanded;
17
+ if (!jsonnet.evaluateSnippet (" " , templatedJSONString, &expanded)) {
18
+ std::cerr << " Error parsing Jsonnet: " +jsonnet.lastError ();
19
+ exit (1 );
20
+ }
21
+ std::string expected = " 2000\n " ;
22
+ assert (expected == expanded);
23
+ return 0 ;
24
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ if [ -z "$DISABLE_LIB_TESTS" ]; then
11
11
LD_LIBRARY_PATH=. ./libjsonnet_test_snippet " ${TEST_SNIPPET} " || FAIL=TRUE
12
12
printf ' libjsonnet_test_file: '
13
13
LD_LIBRARY_PATH=. ./libjsonnet_test_file " test_suite/object.jsonnet" || FAIL=TRUE
14
+ echo -n ' libjsonnet_test_locale: '
15
+ LD_LIBRARY_PATH=. ./libjsonnet_test_locale || FAIL=TRUE
14
16
fi
15
17
examples/check.sh || FAIL=TRUE
16
18
examples/terraform/check.sh || FAIL=TRUE
You can’t perform that action at this time.
0 commit comments