listitem_T *li;
if (rettv_list_alloc(res) == FAIL)
- goto fail;
+ goto failsilent;
++reader->js_used; /* consume the '[' */
while (TRUE)
goto fail;
}
fail:
+ EMSG(_(e_invarg));
+failsilent:
res->v_type = VAR_SPECIAL;
res->vval.v_number = VVAL_NONE;
}
char_u *key;
if (rettv_dict_alloc(res) == FAIL)
- goto fail;
+ goto failsilent;
++reader->js_used; /* consume the '{' */
while (TRUE)
if (key != NULL)
EMSG(_(e_emptykey));
clear_tv(&tvkey);
- goto fail;
+ goto failsilent;
}
json_skip_white(reader);
goto fail;
}
fail:
+ EMSG(_(e_invarg));
+failsilent:
res->v_type = VAR_SPECIAL;
res->vval.v_number = VVAL_NONE;
}
" Test for JSON functions.
+scriptencoding utf-8
let s:json1 = '"str\"in\\g"'
let s:var1 = "str\"in\\g"
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
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
"-------------------------------------------------------------------------------