1
0
forked from aniani/vim

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.
This commit is contained in:
Bram Moolenaar
2016-01-24 15:05:32 +01:00
parent 17a13437c9
commit 6039c7f053
4 changed files with 38 additions and 5 deletions

View File

@@ -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 @@ func Test_decode()
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