patch 7.4.1164
Problem: No tests for comparing special variables. Error in jsondecode()
not reported. test_json does not work Japanse system.
Solution: Set scriptencoding. (Ken Takata) Add a few more tests. Add error.
diff --git a/src/testdir/test_json.vim b/src/testdir/test_json.vim
index b306479..a1cfa93 100644
--- a/src/testdir/test_json.vim
+++ b/src/testdir/test_json.vim
@@ -1,4 +1,5 @@
" Test for JSON functions.
+scriptencoding utf-8
let s:json1 = '"str\"in\\g"'
let s:var1 = "str\"in\\g"
@@ -95,11 +96,25 @@
call assert_equal(type(v:none), type(jsondecode('')))
call assert_equal("", jsondecode('""'))
+ call assert_equal({'n': 1}, jsondecode('{"n":1,}'))
+
call assert_fails('call jsondecode("\"")', "E474:")
- call assert_fails('call jsondecode("{-}")', "E474:")
call assert_fails('call jsondecode("blah")', "E474:")
call assert_fails('call jsondecode("true blah")', "E474:")
call assert_fails('call jsondecode("<foobar>")', "E474:")
- call assert_fails('call jsondecode("[foobar]")', "E474:")
+
+ call assert_fails('call jsondecode("{")', "E474:")
call assert_fails('call jsondecode("{foobar}")', "E474:")
+ call assert_fails('call jsondecode("{\"n\",")', "E474:")
+ call assert_fails('call jsondecode("{\"n\":")', "E474:")
+ call assert_fails('call jsondecode("{\"n\":1")', "E474:")
+ call assert_fails('call jsondecode("{\"n\":1,")', "E474:")
+ call assert_fails('call jsondecode("{\"n\",1}")', "E474:")
+ call assert_fails('call jsondecode("{-}")', "E474:")
+
+ call assert_fails('call jsondecode("[foobar]")', "E474:")
+ call assert_fails('call jsondecode("[")', "E474:")
+ call assert_fails('call jsondecode("[1")', "E474:")
+ call assert_fails('call jsondecode("[1,")', "E474:")
+ call assert_fails('call jsondecode("[1 2]")', "E474:")
endfunc