Mercurial > vim
diff src/testdir/test_json.vim @ 7732:4a4f1dd1abe8 v7.4.1164
commit https://github.com/vim/vim/commit/6039c7f05376f0e470cf62bf2757e653aea357f3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 24 15:05:32 2016 +0100
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 24 Jan 2016 15:15:04 +0100 |
parents | 6ebd8bdf41bc |
children | f2ddad8cbce7 |
line wrap: on
line diff
--- 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 @@ 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