0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 7.4.1304

Problem:    Function names are difficult to read.
Solution:   Rename jsonencode to json_encode, jsondecode to json_decode,
            jsencode to js_encode and jsdecode to js_decode.
This commit is contained in:
Bram Moolenaar
2016-02-11 21:08:32 +01:00
parent b6a4fee37e
commit 7823a3bd2e
4 changed files with 166 additions and 162 deletions

View File

@@ -1846,6 +1846,7 @@ delete( {fname} [, {flags}]) Number delete the file or directory {fname}
did_filetype() Number TRUE if FileType autocommand event used did_filetype() Number TRUE if FileType autocommand event used
diff_filler( {lnum}) Number diff filler lines about {lnum} diff_filler( {lnum}) Number diff filler lines about {lnum}
diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col} diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col}
disable_char_avail_for_testing({expr}) none test without typeahead
empty( {expr}) Number TRUE if {expr} is empty empty( {expr}) Number TRUE if {expr} is empty
escape( {string}, {chars}) String escape {chars} in {string} with '\' escape( {string}, {chars}) String escape {chars} in {string} with '\'
eval( {string}) any evaluate {string} into its value eval( {string}) any evaluate {string} into its value
@@ -1956,10 +1957,10 @@ job_start({command} [, {options}]) Job start a job
job_status( {job}) String get the status of a job job_status( {job}) String get the status of a job
job_stop( {job} [, {how}]) Number stop a job job_stop( {job} [, {how}]) Number stop a job
join( {list} [, {sep}]) String join {list} items into one String join( {list} [, {sep}]) String join {list} items into one String
jsdecode( {string}) any decode JS style JSON js_decode( {string}) any decode JS style JSON
jsencode( {expr}) String encode JS style JSON js_encode( {expr}) String encode JS style JSON
jsondecode( {string}) any decode JSON json_decode( {string}) any decode JSON
jsonencode( {expr}) String encode JSON json_encode( {expr}) String encode JSON
keys( {dict}) List keys in {dict} keys( {dict}) List keys in {dict}
len( {expr}) Number the length of {expr} len( {expr}) Number the length of {expr}
libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg}
@@ -2733,8 +2734,9 @@ copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't
When {expr} is a |List| a shallow copy is created. This means When {expr} is a |List| a shallow copy is created. This means
that the original |List| can be changed without changing the that the original |List| can be changed without changing the
copy, and vice versa. But the items are identical, thus copy, and vice versa. But the items are identical, thus
changing an item changes the contents of both |Lists|. Also changing an item changes the contents of both |Lists|.
see |deepcopy()|. A |Dictionary| is copied in a similar way as a |List|.
Also see |deepcopy()|.
cos({expr}) *cos()* cos({expr}) *cos()*
Return the cosine of {expr}, measured in radians, as a |Float|. Return the cosine of {expr}, measured in radians, as a |Float|.
@@ -4386,30 +4388,30 @@ join({list} [, {sep}]) *join()*
converted into a string like with |string()|. converted into a string like with |string()|.
The opposite function is |split()|. The opposite function is |split()|.
jsdecode({string}) *jsdecode()* js_decode({string}) *js_decode()*
This is similar to |jsondecode()| with these differences: This is similar to |json_decode()| with these differences:
- Object key names do not have to be in quotes. - Object key names do not have to be in quotes.
- Empty items in an array (between two commas) are allowed and - Empty items in an array (between two commas) are allowed and
result in v:none items. result in v:none items.
jsencode({expr}) *jsencode()* js_encode({expr}) *js_encode()*
This is similar to |jsonencode()| with these differences: This is similar to |json_encode()| with these differences:
- Object key names are not in quotes. - Object key names are not in quotes.
- v:none items in an array result in an empty item between - v:none items in an array result in an empty item between
commas. commas.
For example, the Vim object: For example, the Vim object:
[1,v:none,{"one":1}],v:none ~ [1,v:none,{"one":1},v:none] ~
Will be encoded as: Will be encoded as:
[1,,{one:1},,] ~ [1,,{one:1},,] ~
While jsonencode() would produce: While json_encode() would produce:
[1,null,{"one":1},null] ~ [1,null,{"one":1},null] ~
This encoding is valid for JavaScript. It is more efficient This encoding is valid for JavaScript. It is more efficient
than JSON, especially when using an array with optional items. than JSON, especially when using an array with optional items.
jsondecode({string}) *jsondecode()* json_decode({string}) *json_decode()*
This parses a JSON formatted string and returns the equivalent This parses a JSON formatted string and returns the equivalent
in Vim values. See |jsonencode()| for the relation between in Vim values. See |json_encode()| for the relation between
JSON and Vim values. JSON and Vim values.
The decoding is permissive: The decoding is permissive:
- A trailing comma in an array and object is ignored. - A trailing comma in an array and object is ignored.
@@ -4419,7 +4421,7 @@ jsondecode({string}) *jsondecode()*
- An empty object member name is not allowed. - An empty object member name is not allowed.
- Duplicate object member names are not allowed. - Duplicate object member names are not allowed.
jsonencode({expr}) *jsonencode()* json_encode({expr}) *json_encode()*
Encode {expr} as JSON and return this as a string. Encode {expr} as JSON and return this as a string.
The encoding is specified in: The encoding is specified in:
https://tools.ietf.org/html/rfc7159.html https://tools.ietf.org/html/rfc7159.html

View File

@@ -629,10 +629,10 @@ static void f_job_stop(typval_T *argvars, typval_T *rettv);
static void f_job_status(typval_T *argvars, typval_T *rettv); static void f_job_status(typval_T *argvars, typval_T *rettv);
#endif #endif
static void f_join(typval_T *argvars, typval_T *rettv); static void f_join(typval_T *argvars, typval_T *rettv);
static void f_jsdecode(typval_T *argvars, typval_T *rettv); static void f_js_decode(typval_T *argvars, typval_T *rettv);
static void f_jsencode(typval_T *argvars, typval_T *rettv); static void f_js_encode(typval_T *argvars, typval_T *rettv);
static void f_jsondecode(typval_T *argvars, typval_T *rettv); static void f_json_decode(typval_T *argvars, typval_T *rettv);
static void f_jsonencode(typval_T *argvars, typval_T *rettv); static void f_json_encode(typval_T *argvars, typval_T *rettv);
static void f_keys(typval_T *argvars, typval_T *rettv); static void f_keys(typval_T *argvars, typval_T *rettv);
static void f_last_buffer_nr(typval_T *argvars, typval_T *rettv); static void f_last_buffer_nr(typval_T *argvars, typval_T *rettv);
static void f_len(typval_T *argvars, typval_T *rettv); static void f_len(typval_T *argvars, typval_T *rettv);
@@ -8213,10 +8213,10 @@ static struct fst
{"job_stop", 1, 2, f_job_stop}, {"job_stop", 1, 2, f_job_stop},
#endif #endif
{"join", 1, 2, f_join}, {"join", 1, 2, f_join},
{"jsdecode", 1, 1, f_jsdecode}, {"js_decode", 1, 1, f_js_decode},
{"jsencode", 1, 1, f_jsencode}, {"js_encode", 1, 1, f_js_encode},
{"jsondecode", 1, 1, f_jsondecode}, {"json_decode", 1, 1, f_json_decode},
{"jsonencode", 1, 1, f_jsonencode}, {"json_encode", 1, 1, f_json_encode},
{"keys", 1, 1, f_keys}, {"keys", 1, 1, f_keys},
{"last_buffer_nr", 0, 0, f_last_buffer_nr},/* obsolete */ {"last_buffer_nr", 0, 0, f_last_buffer_nr},/* obsolete */
{"len", 1, 1, f_len}, {"len", 1, 1, f_len},
@@ -14488,10 +14488,10 @@ f_join(typval_T *argvars, typval_T *rettv)
} }
/* /*
* "jsdecode()" function * "js_decode()" function
*/ */
static void static void
f_jsdecode(typval_T *argvars, typval_T *rettv) f_js_decode(typval_T *argvars, typval_T *rettv)
{ {
js_read_T reader; js_read_T reader;
@@ -14503,20 +14503,20 @@ f_jsdecode(typval_T *argvars, typval_T *rettv)
} }
/* /*
* "jsencode()" function * "js_encode()" function
*/ */
static void static void
f_jsencode(typval_T *argvars, typval_T *rettv) f_js_encode(typval_T *argvars, typval_T *rettv)
{ {
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = json_encode(&argvars[0], JSON_JS); rettv->vval.v_string = json_encode(&argvars[0], JSON_JS);
} }
/* /*
* "jsondecode()" function * "json_decode()" function
*/ */
static void static void
f_jsondecode(typval_T *argvars, typval_T *rettv) f_json_decode(typval_T *argvars, typval_T *rettv)
{ {
js_read_T reader; js_read_T reader;
@@ -14528,10 +14528,10 @@ f_jsondecode(typval_T *argvars, typval_T *rettv)
} }
/* /*
* "jsonencode()" function * "json_encode()" function
*/ */
static void static void
f_jsonencode(typval_T *argvars, typval_T *rettv) f_json_encode(typval_T *argvars, typval_T *rettv)
{ {
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = json_encode(&argvars[0], 0); rettv->vval.v_string = json_encode(&argvars[0], 0);

View File

@@ -55,199 +55,199 @@ let s:jsonvals = '[true,false,null,null]'
let s:varvals = [v:true, v:false, v:null, v:null] let s:varvals = [v:true, v:false, v:null, v:null]
func Test_json_encode() func Test_json_encode()
call assert_equal(s:json1, jsonencode(s:var1)) call assert_equal(s:json1, json_encode(s:var1))
call assert_equal(s:json2, jsonencode(s:var2)) call assert_equal(s:json2, json_encode(s:var2))
call assert_equal(s:json3, jsonencode(s:var3)) call assert_equal(s:json3, json_encode(s:var3))
call assert_equal(s:json4, jsonencode(s:var4)) call assert_equal(s:json4, json_encode(s:var4))
call assert_equal(s:json5, jsonencode(s:var5)) call assert_equal(s:json5, json_encode(s:var5))
if has('multi_byte') if has('multi_byte')
call assert_equal(s:jsonmb, jsonencode(s:varmb)) call assert_equal(s:jsonmb, json_encode(s:varmb))
endif endif
call assert_equal(s:jsonnr, jsonencode(s:varnr)) call assert_equal(s:jsonnr, json_encode(s:varnr))
if has('float') if has('float')
call assert_equal(s:jsonfl, jsonencode(s:varfl)) call assert_equal(s:jsonfl, json_encode(s:varfl))
endif endif
call assert_equal(s:jsonl1, jsonencode(s:varl1)) call assert_equal(s:jsonl1, json_encode(s:varl1))
call assert_equal(s:jsonl2, jsonencode(s:varl2)) call assert_equal(s:jsonl2, json_encode(s:varl2))
call assert_equal(s:jsonl3, jsonencode(s:varl3)) call assert_equal(s:jsonl3, json_encode(s:varl3))
call assert_equal(s:jsond1, jsonencode(s:vard1)) call assert_equal(s:jsond1, json_encode(s:vard1))
call assert_equal(s:jsond2, jsonencode(s:vard2)) call assert_equal(s:jsond2, json_encode(s:vard2))
call assert_equal(s:jsond3, jsonencode(s:vard3)) call assert_equal(s:jsond3, json_encode(s:vard3))
call assert_equal(s:jsond4, jsonencode(s:vard4)) call assert_equal(s:jsond4, json_encode(s:vard4))
call assert_equal(s:jsonvals, jsonencode(s:varvals)) call assert_equal(s:jsonvals, json_encode(s:varvals))
call assert_fails('echo jsonencode(function("tr"))', 'E474:') call assert_fails('echo json_encode(function("tr"))', 'E474:')
call assert_fails('echo jsonencode([function("tr")])', 'E474:') call assert_fails('echo json_encode([function("tr")])', 'E474:')
silent! let res = jsonencode(function("tr")) silent! let res = json_encode(function("tr"))
call assert_equal("", res) call assert_equal("", res)
endfunc endfunc
func Test_json_decode() func Test_json_decode()
call assert_equal(s:var1, jsondecode(s:json1)) call assert_equal(s:var1, json_decode(s:json1))
call assert_equal(s:var2, jsondecode(s:json2)) call assert_equal(s:var2, json_decode(s:json2))
call assert_equal(s:var3, jsondecode(s:json3)) call assert_equal(s:var3, json_decode(s:json3))
call assert_equal(s:var4, jsondecode(s:json4)) call assert_equal(s:var4, json_decode(s:json4))
call assert_equal(s:var5, jsondecode(s:json5)) call assert_equal(s:var5, json_decode(s:json5))
if has('multi_byte') if has('multi_byte')
call assert_equal(s:varmb, jsondecode(s:jsonmb)) call assert_equal(s:varmb, json_decode(s:jsonmb))
endif endif
call assert_equal(s:varnr, jsondecode(s:jsonnr)) call assert_equal(s:varnr, json_decode(s:jsonnr))
if has('float') if has('float')
call assert_equal(s:varfl, jsondecode(s:jsonfl)) call assert_equal(s:varfl, json_decode(s:jsonfl))
endif endif
call assert_equal(s:varl1, jsondecode(s:jsonl1)) call assert_equal(s:varl1, json_decode(s:jsonl1))
call assert_equal(s:varl2x, jsondecode(s:jsonl2)) call assert_equal(s:varl2x, json_decode(s:jsonl2))
call assert_equal(s:varl2x, jsondecode(s:jsonl2s)) call assert_equal(s:varl2x, json_decode(s:jsonl2s))
call assert_equal(s:varl3, jsondecode(s:jsonl3)) call assert_equal(s:varl3, json_decode(s:jsonl3))
call assert_equal(s:vard1, jsondecode(s:jsond1)) call assert_equal(s:vard1, json_decode(s:jsond1))
call assert_equal(s:vard2x, jsondecode(s:jsond2)) call assert_equal(s:vard2x, json_decode(s:jsond2))
call assert_equal(s:vard2x, jsondecode(s:jsond2s)) call assert_equal(s:vard2x, json_decode(s:jsond2s))
call assert_equal(s:vard3, jsondecode(s:jsond3)) call assert_equal(s:vard3, json_decode(s:jsond3))
call assert_equal(s:vard4x, jsondecode(s:jsond4)) call assert_equal(s:vard4x, json_decode(s:jsond4))
call assert_equal(s:varvals, jsondecode(s:jsonvals)) call assert_equal(s:varvals, json_decode(s:jsonvals))
call assert_equal(v:true, jsondecode('true')) call assert_equal(v:true, json_decode('true'))
call assert_equal(type(v:true), type(jsondecode('true'))) call assert_equal(type(v:true), type(json_decode('true')))
call assert_equal(v:none, jsondecode('')) call assert_equal(v:none, json_decode(''))
call assert_equal(type(v:none), type(jsondecode(''))) call assert_equal(type(v:none), type(json_decode('')))
call assert_equal("", jsondecode('""')) call assert_equal("", json_decode('""'))
call assert_equal({'n': 1}, jsondecode('{"n":1,}')) call assert_equal({'n': 1}, json_decode('{"n":1,}'))
call assert_fails('call jsondecode("\"")', "E474:") call assert_fails('call json_decode("\"")', "E474:")
call assert_fails('call jsondecode("blah")', "E474:") call assert_fails('call json_decode("blah")', "E474:")
call assert_fails('call jsondecode("true blah")', "E474:") call assert_fails('call json_decode("true blah")', "E474:")
call assert_fails('call jsondecode("<foobar>")', "E474:") call assert_fails('call json_decode("<foobar>")', "E474:")
call assert_fails('call jsondecode("{")', "E474:") call assert_fails('call json_decode("{")', "E474:")
call assert_fails('call jsondecode("{foobar}")', "E474:") call assert_fails('call json_decode("{foobar}")', "E474:")
call assert_fails('call jsondecode("{\"n\",")', "E474:") call assert_fails('call json_decode("{\"n\",")', "E474:")
call assert_fails('call jsondecode("{\"n\":")', "E474:") call assert_fails('call json_decode("{\"n\":")', "E474:")
call assert_fails('call jsondecode("{\"n\":1")', "E474:") call assert_fails('call json_decode("{\"n\":1")', "E474:")
call assert_fails('call jsondecode("{\"n\":1,")', "E474:") call assert_fails('call json_decode("{\"n\":1,")', "E474:")
call assert_fails('call jsondecode("{\"n\",1}")', "E474:") call assert_fails('call json_decode("{\"n\",1}")', "E474:")
call assert_fails('call jsondecode("{-}")', "E474:") call assert_fails('call json_decode("{-}")', "E474:")
call assert_fails('call jsondecode("[foobar]")', "E474:") call assert_fails('call json_decode("[foobar]")', "E474:")
call assert_fails('call jsondecode("[")', "E474:") call assert_fails('call json_decode("[")', "E474:")
call assert_fails('call jsondecode("[1")', "E474:") call assert_fails('call json_decode("[1")', "E474:")
call assert_fails('call jsondecode("[1,")', "E474:") call assert_fails('call json_decode("[1,")', "E474:")
call assert_fails('call jsondecode("[1 2]")', "E474:") call assert_fails('call json_decode("[1 2]")', "E474:")
call assert_fails('call jsondecode("[1,,2]")', "E474:") call assert_fails('call json_decode("[1,,2]")', "E474:")
endfunc endfunc
let s:jsl5 = '[7,,,]' let s:jsl5 = '[7,,,]'
let s:varl5 = [7, v:none, v:none] let s:varl5 = [7, v:none, v:none]
func Test_js_encode() func Test_js_encode()
call assert_equal(s:json1, jsencode(s:var1)) call assert_equal(s:json1, js_encode(s:var1))
call assert_equal(s:json2, jsencode(s:var2)) call assert_equal(s:json2, js_encode(s:var2))
call assert_equal(s:json3, jsencode(s:var3)) call assert_equal(s:json3, js_encode(s:var3))
call assert_equal(s:json4, jsencode(s:var4)) call assert_equal(s:json4, js_encode(s:var4))
call assert_equal(s:json5, jsencode(s:var5)) call assert_equal(s:json5, js_encode(s:var5))
if has('multi_byte') if has('multi_byte')
call assert_equal(s:jsonmb, jsencode(s:varmb)) call assert_equal(s:jsonmb, js_encode(s:varmb))
endif endif
call assert_equal(s:jsonnr, jsencode(s:varnr)) call assert_equal(s:jsonnr, js_encode(s:varnr))
if has('float') if has('float')
call assert_equal(s:jsonfl, jsencode(s:varfl)) call assert_equal(s:jsonfl, js_encode(s:varfl))
endif endif
call assert_equal(s:jsonl1, jsencode(s:varl1)) call assert_equal(s:jsonl1, js_encode(s:varl1))
call assert_equal(s:jsonl2, jsencode(s:varl2)) call assert_equal(s:jsonl2, js_encode(s:varl2))
call assert_equal(s:jsonl3, jsencode(s:varl3)) call assert_equal(s:jsonl3, js_encode(s:varl3))
call assert_equal(s:jsd1, jsencode(s:vard1)) call assert_equal(s:jsd1, js_encode(s:vard1))
call assert_equal(s:jsd2, jsencode(s:vard2)) call assert_equal(s:jsd2, js_encode(s:vard2))
call assert_equal(s:jsd3, jsencode(s:vard3)) call assert_equal(s:jsd3, js_encode(s:vard3))
call assert_equal(s:jsd4, jsencode(s:vard4)) call assert_equal(s:jsd4, js_encode(s:vard4))
call assert_equal(s:jsonvals, jsencode(s:varvals)) call assert_equal(s:jsonvals, js_encode(s:varvals))
call assert_fails('echo jsencode(function("tr"))', 'E474:') call assert_fails('echo js_encode(function("tr"))', 'E474:')
call assert_fails('echo jsencode([function("tr")])', 'E474:') call assert_fails('echo js_encode([function("tr")])', 'E474:')
silent! let res = jsencode(function("tr")) silent! let res = js_encode(function("tr"))
call assert_equal("", res) call assert_equal("", res)
call assert_equal(s:jsl5, jsencode(s:varl5)) call assert_equal(s:jsl5, js_encode(s:varl5))
endfunc endfunc
func Test_js_decode() func Test_js_decode()
call assert_equal(s:var1, jsdecode(s:json1)) call assert_equal(s:var1, js_decode(s:json1))
call assert_equal(s:var2, jsdecode(s:json2)) call assert_equal(s:var2, js_decode(s:json2))
call assert_equal(s:var3, jsdecode(s:json3)) call assert_equal(s:var3, js_decode(s:json3))
call assert_equal(s:var4, jsdecode(s:json4)) call assert_equal(s:var4, js_decode(s:json4))
call assert_equal(s:var5, jsdecode(s:json5)) call assert_equal(s:var5, js_decode(s:json5))
if has('multi_byte') if has('multi_byte')
call assert_equal(s:varmb, jsdecode(s:jsonmb)) call assert_equal(s:varmb, js_decode(s:jsonmb))
endif endif
call assert_equal(s:varnr, jsdecode(s:jsonnr)) call assert_equal(s:varnr, js_decode(s:jsonnr))
if has('float') if has('float')
call assert_equal(s:varfl, jsdecode(s:jsonfl)) call assert_equal(s:varfl, js_decode(s:jsonfl))
endif endif
call assert_equal(s:varl1, jsdecode(s:jsonl1)) call assert_equal(s:varl1, js_decode(s:jsonl1))
call assert_equal(s:varl2x, jsdecode(s:jsonl2)) call assert_equal(s:varl2x, js_decode(s:jsonl2))
call assert_equal(s:varl2x, jsdecode(s:jsonl2s)) call assert_equal(s:varl2x, js_decode(s:jsonl2s))
call assert_equal(s:varl3, jsdecode(s:jsonl3)) call assert_equal(s:varl3, js_decode(s:jsonl3))
call assert_equal(s:vard1, jsdecode(s:jsond1)) call assert_equal(s:vard1, js_decode(s:jsond1))
call assert_equal(s:vard1, jsdecode(s:jsd1)) call assert_equal(s:vard1, js_decode(s:jsd1))
call assert_equal(s:vard2x, jsdecode(s:jsond2)) call assert_equal(s:vard2x, js_decode(s:jsond2))
call assert_equal(s:vard2x, jsdecode(s:jsd2)) call assert_equal(s:vard2x, js_decode(s:jsd2))
call assert_equal(s:vard2x, jsdecode(s:jsond2s)) call assert_equal(s:vard2x, js_decode(s:jsond2s))
call assert_equal(s:vard2x, jsdecode(s:jsd2s)) call assert_equal(s:vard2x, js_decode(s:jsd2s))
call assert_equal(s:vard3, jsdecode(s:jsond3)) call assert_equal(s:vard3, js_decode(s:jsond3))
call assert_equal(s:vard3, jsdecode(s:jsd3)) call assert_equal(s:vard3, js_decode(s:jsd3))
call assert_equal(s:vard4x, jsdecode(s:jsond4)) call assert_equal(s:vard4x, js_decode(s:jsond4))
call assert_equal(s:vard4x, jsdecode(s:jsd4)) call assert_equal(s:vard4x, js_decode(s:jsd4))
call assert_equal(s:varvals, jsdecode(s:jsonvals)) call assert_equal(s:varvals, js_decode(s:jsonvals))
call assert_equal(v:true, jsdecode('true')) call assert_equal(v:true, js_decode('true'))
call assert_equal(type(v:true), type(jsdecode('true'))) call assert_equal(type(v:true), type(js_decode('true')))
call assert_equal(v:none, jsdecode('')) call assert_equal(v:none, js_decode(''))
call assert_equal(type(v:none), type(jsdecode(''))) call assert_equal(type(v:none), type(js_decode('')))
call assert_equal("", jsdecode('""')) call assert_equal("", js_decode('""'))
call assert_equal({'n': 1}, jsdecode('{"n":1,}')) call assert_equal({'n': 1}, js_decode('{"n":1,}'))
call assert_fails('call jsdecode("\"")', "E474:") call assert_fails('call js_decode("\"")', "E474:")
call assert_fails('call jsdecode("blah")', "E474:") call assert_fails('call js_decode("blah")', "E474:")
call assert_fails('call jsdecode("true blah")', "E474:") call assert_fails('call js_decode("true blah")', "E474:")
call assert_fails('call jsdecode("<foobar>")', "E474:") call assert_fails('call js_decode("<foobar>")', "E474:")
call assert_fails('call jsdecode("{")', "E474:") call assert_fails('call js_decode("{")', "E474:")
call assert_fails('call jsdecode("{foobar}")', "E474:") call assert_fails('call js_decode("{foobar}")', "E474:")
call assert_fails('call jsdecode("{\"n\",")', "E474:") call assert_fails('call js_decode("{\"n\",")', "E474:")
call assert_fails('call jsdecode("{\"n\":")', "E474:") call assert_fails('call js_decode("{\"n\":")', "E474:")
call assert_fails('call jsdecode("{\"n\":1")', "E474:") call assert_fails('call js_decode("{\"n\":1")', "E474:")
call assert_fails('call jsdecode("{\"n\":1,")', "E474:") call assert_fails('call js_decode("{\"n\":1,")', "E474:")
call assert_fails('call jsdecode("{\"n\",1}")', "E474:") call assert_fails('call js_decode("{\"n\",1}")', "E474:")
call assert_fails('call jsdecode("{-}")', "E474:") call assert_fails('call js_decode("{-}")', "E474:")
call assert_fails('call jsdecode("[foobar]")', "E474:") call assert_fails('call js_decode("[foobar]")', "E474:")
call assert_fails('call jsdecode("[")', "E474:") call assert_fails('call js_decode("[")', "E474:")
call assert_fails('call jsdecode("[1")', "E474:") call assert_fails('call js_decode("[1")', "E474:")
call assert_fails('call jsdecode("[1,")', "E474:") call assert_fails('call js_decode("[1,")', "E474:")
call assert_fails('call jsdecode("[1 2]")', "E474:") call assert_fails('call js_decode("[1 2]")', "E474:")
call assert_equal(s:varl5, jsdecode(s:jsl5)) call assert_equal(s:varl5, js_decode(s:jsl5))
endfunc endfunc

View File

@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1304,
/**/ /**/
1303, 1303,
/**/ /**/