]> granicus.if.org Git - vim/commitdiff
patch 7.4.1164 v7.4.1164
authorBram Moolenaar <Bram@vim.org>
Sun, 24 Jan 2016 14:05:32 +0000 (15:05 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 24 Jan 2016 14:05:32 +0000 (15:05 +0100)
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.

src/json.c
src/testdir/test_json.vim
src/testdir/test_viml.vim
src/version.c

index accb6cf85d17ad90740fc24c3284b60170de91d0..e4473830a694c39f1d421acdf9257a463e3d49e8 100644 (file)
@@ -220,7 +220,7 @@ json_decode_array(js_read_T *reader, typval_T *res)
     listitem_T *li;
 
     if (rettv_list_alloc(res) == FAIL)
-       goto fail;
+       goto failsilent;
     ++reader->js_used; /* consume the '[' */
 
     while (TRUE)
@@ -253,6 +253,8 @@ json_decode_array(js_read_T *reader, typval_T *res)
            goto fail;
     }
 fail:
+    EMSG(_(e_invarg));
+failsilent:
     res->v_type = VAR_SPECIAL;
     res->vval.v_number = VVAL_NONE;
 }
@@ -268,7 +270,7 @@ json_decode_object(js_read_T *reader, typval_T *res)
     char_u     *key;
 
     if (rettv_dict_alloc(res) == FAIL)
-       goto fail;
+       goto failsilent;
     ++reader->js_used; /* consume the '{' */
 
     while (TRUE)
@@ -293,7 +295,7 @@ json_decode_object(js_read_T *reader, typval_T *res)
            if (key != NULL)
                EMSG(_(e_emptykey));
            clear_tv(&tvkey);
-           goto fail;
+           goto failsilent;
        }
 
        json_skip_white(reader);
@@ -329,6 +331,8 @@ json_decode_object(js_read_T *reader, typval_T *res)
            goto fail;
     }
 fail:
+    EMSG(_(e_invarg));
+failsilent:
     res->v_type = VAR_SPECIAL;
     res->vval.v_number = VVAL_NONE;
 }
index b30647947fdb3aceb5d5056c68a85f37a6c786a1..a1cfa93ac88652dd6a8970bbbaf7cd4319229f21 100644 (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
index f1a7cb43517b8348440325e97545f1fe3dbe8bb4..645f1b522e7c719bb564aabf7d1d483df63ff411 100644 (file)
@@ -946,6 +946,18 @@ func Test_type()
     call assert_equal('true', '' . v:true)
     call assert_equal('none', '' . v:none)
     call assert_equal('null', '' . v:null)
+
+    call assert_true(v:false == 0)
+    call assert_false(v:false != 0)
+    call assert_true(v:true == 1)
+    call assert_false(v:true != 1)
+    call assert_false(v:true == v:false)
+    call assert_true(v:true != v:false)
+
+    call assert_true(v:null == 0)
+    call assert_false(v:null != 0)
+    call assert_true(v:none == 0)
+    call assert_false(v:none != 0)
 endfunc
 
 "-------------------------------------------------------------------------------
index 60cb07c34807da39c8fba446ff5afe954839b277..c41230921b931dd51d3f3c9a7ebffa0756a8ca46 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1164,
 /**/
     1163,
 /**/