summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-02-11 21:08:32 +0100
committerBram Moolenaar <Bram@vim.org>2016-02-11 21:08:32 +0100
commit7823a3bd2eed6ff9e544d201de96710bd5344aaf (patch)
treee95946654a7bc04fe643f3ee53f62f71f690241f /src/testdir
parentb6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d (diff)
downloadvim-7823a3bd2eed6ff9e544d201de96710bd5344aaf.zip
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.
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_json.vim288
1 files changed, 144 insertions, 144 deletions
diff --git a/src/testdir/test_json.vim b/src/testdir/test_json.vim
index 2534de113..3ac936f8a 100644
--- a/src/testdir/test_json.vim
+++ b/src/testdir/test_json.vim
@@ -55,199 +55,199 @@ let s:jsonvals = '[true,false,null,null]'
let s:varvals = [v:true, v:false, v:null, v:null]
func Test_json_encode()
- call assert_equal(s:json1, jsonencode(s:var1))
- call assert_equal(s:json2, jsonencode(s:var2))
- call assert_equal(s:json3, jsonencode(s:var3))
- call assert_equal(s:json4, jsonencode(s:var4))
- call assert_equal(s:json5, jsonencode(s:var5))
+ call assert_equal(s:json1, json_encode(s:var1))
+ call assert_equal(s:json2, json_encode(s:var2))
+ call assert_equal(s:json3, json_encode(s:var3))
+ call assert_equal(s:json4, json_encode(s:var4))
+ call assert_equal(s:json5, json_encode(s:var5))
if has('multi_byte')
- call assert_equal(s:jsonmb, jsonencode(s:varmb))
+ call assert_equal(s:jsonmb, json_encode(s:varmb))
endif
- call assert_equal(s:jsonnr, jsonencode(s:varnr))
+ call assert_equal(s:jsonnr, json_encode(s:varnr))
if has('float')
- call assert_equal(s:jsonfl, jsonencode(s:varfl))
+ call assert_equal(s:jsonfl, json_encode(s:varfl))
endif
- call assert_equal(s:jsonl1, jsonencode(s:varl1))
- call assert_equal(s:jsonl2, jsonencode(s:varl2))
- call assert_equal(s:jsonl3, jsonencode(s:varl3))
+ call assert_equal(s:jsonl1, json_encode(s:varl1))
+ call assert_equal(s:jsonl2, json_encode(s:varl2))
+ call assert_equal(s:jsonl3, json_encode(s:varl3))
- call assert_equal(s:jsond1, jsonencode(s:vard1))
- call assert_equal(s:jsond2, jsonencode(s:vard2))
- call assert_equal(s:jsond3, jsonencode(s:vard3))
- call assert_equal(s:jsond4, jsonencode(s:vard4))
+ call assert_equal(s:jsond1, json_encode(s:vard1))
+ call assert_equal(s:jsond2, json_encode(s:vard2))
+ call assert_equal(s:jsond3, json_encode(s:vard3))
+ 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 jsonencode([function("tr")])', 'E474:')
+ call assert_fails('echo json_encode(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)
endfunc
func Test_json_decode()
- call assert_equal(s:var1, jsondecode(s:json1))
- call assert_equal(s:var2, jsondecode(s:json2))
- call assert_equal(s:var3, jsondecode(s:json3))
- call assert_equal(s:var4, jsondecode(s:json4))
- call assert_equal(s:var5, jsondecode(s:json5))
+ call assert_equal(s:var1, json_decode(s:json1))
+ call assert_equal(s:var2, json_decode(s:json2))
+ call assert_equal(s:var3, json_decode(s:json3))
+ call assert_equal(s:var4, json_decode(s:json4))
+ call assert_equal(s:var5, json_decode(s:json5))
if has('multi_byte')
- call assert_equal(s:varmb, jsondecode(s:jsonmb))
+ call assert_equal(s:varmb, json_decode(s:jsonmb))
endif
- call assert_equal(s:varnr, jsondecode(s:jsonnr))
+ call assert_equal(s:varnr, json_decode(s:jsonnr))
if has('float')
- call assert_equal(s:varfl, jsondecode(s:jsonfl))
+ call assert_equal(s:varfl, json_decode(s:jsonfl))
endif
- call assert_equal(s:varl1, jsondecode(s:jsonl1))
- call assert_equal(s:varl2x, jsondecode(s:jsonl2))
- call assert_equal(s:varl2x, jsondecode(s:jsonl2s))
- call assert_equal(s:varl3, jsondecode(s:jsonl3))
-
- call assert_equal(s:vard1, jsondecode(s:jsond1))
- call assert_equal(s:vard2x, jsondecode(s:jsond2))
- call assert_equal(s:vard2x, jsondecode(s:jsond2s))
- call assert_equal(s:vard3, jsondecode(s:jsond3))
- call assert_equal(s:vard4x, jsondecode(s:jsond4))
-
- call assert_equal(s:varvals, jsondecode(s:jsonvals))
-
- call assert_equal(v:true, jsondecode('true'))
- call assert_equal(type(v:true), type(jsondecode('true')))
- call assert_equal(v:none, jsondecode(''))
- 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("blah")', "E474:")
- call assert_fails('call jsondecode("true blah")', "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:")
-
- call assert_fails('call jsondecode("[1,,2]")', "E474:")
+ call assert_equal(s:varl1, json_decode(s:jsonl1))
+ call assert_equal(s:varl2x, json_decode(s:jsonl2))
+ call assert_equal(s:varl2x, json_decode(s:jsonl2s))
+ call assert_equal(s:varl3, json_decode(s:jsonl3))
+
+ call assert_equal(s:vard1, json_decode(s:jsond1))
+ call assert_equal(s:vard2x, json_decode(s:jsond2))
+ call assert_equal(s:vard2x, json_decode(s:jsond2s))
+ call assert_equal(s:vard3, json_decode(s:jsond3))
+ call assert_equal(s:vard4x, json_decode(s:jsond4))
+
+ call assert_equal(s:varvals, json_decode(s:jsonvals))
+
+ call assert_equal(v:true, json_decode('true'))
+ call assert_equal(type(v:true), type(json_decode('true')))
+ call assert_equal(v:none, json_decode(''))
+ call assert_equal(type(v:none), type(json_decode('')))
+ call assert_equal("", json_decode('""'))
+
+ call assert_equal({'n': 1}, json_decode('{"n":1,}'))
+
+ call assert_fails('call json_decode("\"")', "E474:")
+ call assert_fails('call json_decode("blah")', "E474:")
+ call assert_fails('call json_decode("true blah")', "E474:")
+ call assert_fails('call json_decode("<foobar>")', "E474:")
+
+ call assert_fails('call json_decode("{")', "E474:")
+ call assert_fails('call json_decode("{foobar}")', "E474:")
+ call assert_fails('call json_decode("{\"n\",")', "E474:")
+ call assert_fails('call json_decode("{\"n\":")', "E474:")
+ call assert_fails('call json_decode("{\"n\":1")', "E474:")
+ call assert_fails('call json_decode("{\"n\":1,")', "E474:")
+ call assert_fails('call json_decode("{\"n\",1}")', "E474:")
+ call assert_fails('call json_decode("{-}")', "E474:")
+
+ call assert_fails('call json_decode("[foobar]")', "E474:")
+ call assert_fails('call json_decode("[")', "E474:")
+ call assert_fails('call json_decode("[1")', "E474:")
+ call assert_fails('call json_decode("[1,")', "E474:")
+ call assert_fails('call json_decode("[1 2]")', "E474:")
+
+ call assert_fails('call json_decode("[1,,2]")', "E474:")
endfunc
let s:jsl5 = '[7,,,]'
let s:varl5 = [7, v:none, v:none]
func Test_js_encode()
- call assert_equal(s:json1, jsencode(s:var1))
- call assert_equal(s:json2, jsencode(s:var2))
- call assert_equal(s:json3, jsencode(s:var3))
- call assert_equal(s:json4, jsencode(s:var4))
- call assert_equal(s:json5, jsencode(s:var5))
+ call assert_equal(s:json1, js_encode(s:var1))
+ call assert_equal(s:json2, js_encode(s:var2))
+ call assert_equal(s:json3, js_encode(s:var3))
+ call assert_equal(s:json4, js_encode(s:var4))
+ call assert_equal(s:json5, js_encode(s:var5))
if has('multi_byte')
- call assert_equal(s:jsonmb, jsencode(s:varmb))
+ call assert_equal(s:jsonmb, js_encode(s:varmb))
endif
- call assert_equal(s:jsonnr, jsencode(s:varnr))
+ call assert_equal(s:jsonnr, js_encode(s:varnr))
if has('float')
- call assert_equal(s:jsonfl, jsencode(s:varfl))
+ call assert_equal(s:jsonfl, js_encode(s:varfl))
endif
- call assert_equal(s:jsonl1, jsencode(s:varl1))
- call assert_equal(s:jsonl2, jsencode(s:varl2))
- call assert_equal(s:jsonl3, jsencode(s:varl3))
+ call assert_equal(s:jsonl1, js_encode(s:varl1))
+ call assert_equal(s:jsonl2, js_encode(s:varl2))
+ call assert_equal(s:jsonl3, js_encode(s:varl3))
- call assert_equal(s:jsd1, jsencode(s:vard1))
- call assert_equal(s:jsd2, jsencode(s:vard2))
- call assert_equal(s:jsd3, jsencode(s:vard3))
- call assert_equal(s:jsd4, jsencode(s:vard4))
+ call assert_equal(s:jsd1, js_encode(s:vard1))
+ call assert_equal(s:jsd2, js_encode(s:vard2))
+ call assert_equal(s:jsd3, js_encode(s:vard3))
+ 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 jsencode([function("tr")])', 'E474:')
+ call assert_fails('echo js_encode(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(s:jsl5, jsencode(s:varl5))
+ call assert_equal(s:jsl5, js_encode(s:varl5))
endfunc
func Test_js_decode()
- call assert_equal(s:var1, jsdecode(s:json1))
- call assert_equal(s:var2, jsdecode(s:json2))
- call assert_equal(s:var3, jsdecode(s:json3))
- call assert_equal(s:var4, jsdecode(s:json4))
- call assert_equal(s:var5, jsdecode(s:json5))
+ call assert_equal(s:var1, js_decode(s:json1))
+ call assert_equal(s:var2, js_decode(s:json2))
+ call assert_equal(s:var3, js_decode(s:json3))
+ call assert_equal(s:var4, js_decode(s:json4))
+ call assert_equal(s:var5, js_decode(s:json5))
if has('multi_byte')
- call assert_equal(s:varmb, jsdecode(s:jsonmb))
+ call assert_equal(s:varmb, js_decode(s:jsonmb))
endif
- call assert_equal(s:varnr, jsdecode(s:jsonnr))
+ call assert_equal(s:varnr, js_decode(s:jsonnr))
if has('float')
- call assert_equal(s:varfl, jsdecode(s:jsonfl))
+ call assert_equal(s:varfl, js_decode(s:jsonfl))
endif
- call assert_equal(s:varl1, jsdecode(s:jsonl1))
- call assert_equal(s:varl2x, jsdecode(s:jsonl2))
- call assert_equal(s:varl2x, jsdecode(s:jsonl2s))
- call assert_equal(s:varl3, jsdecode(s:jsonl3))
-
- call assert_equal(s:vard1, jsdecode(s:jsond1))
- call assert_equal(s:vard1, jsdecode(s:jsd1))
- call assert_equal(s:vard2x, jsdecode(s:jsond2))
- call assert_equal(s:vard2x, jsdecode(s:jsd2))
- call assert_equal(s:vard2x, jsdecode(s:jsond2s))
- call assert_equal(s:vard2x, jsdecode(s:jsd2s))
- call assert_equal(s:vard3, jsdecode(s:jsond3))
- call assert_equal(s:vard3, jsdecode(s:jsd3))
- call assert_equal(s:vard4x, jsdecode(s:jsond4))
- call assert_equal(s:vard4x, jsdecode(s:jsd4))
-
- call assert_equal(s:varvals, jsdecode(s:jsonvals))
-
- call assert_equal(v:true, jsdecode('true'))
- call assert_equal(type(v:true), type(jsdecode('true')))
- call assert_equal(v:none, jsdecode(''))
- call assert_equal(type(v:none), type(jsdecode('')))
- call assert_equal("", jsdecode('""'))
-
- call assert_equal({'n': 1}, jsdecode('{"n":1,}'))
-
- call assert_fails('call jsdecode("\"")', "E474:")
- call assert_fails('call jsdecode("blah")', "E474:")
- call assert_fails('call jsdecode("true blah")', "E474:")
- call assert_fails('call jsdecode("<foobar>")', "E474:")
-
- call assert_fails('call jsdecode("{")', "E474:")
- call assert_fails('call jsdecode("{foobar}")', "E474:")
- call assert_fails('call jsdecode("{\"n\",")', "E474:")
- call assert_fails('call jsdecode("{\"n\":")', "E474:")
- call assert_fails('call jsdecode("{\"n\":1")', "E474:")
- call assert_fails('call jsdecode("{\"n\":1,")', "E474:")
- call assert_fails('call jsdecode("{\"n\",1}")', "E474:")
- call assert_fails('call jsdecode("{-}")', "E474:")
-
- call assert_fails('call jsdecode("[foobar]")', "E474:")
- call assert_fails('call jsdecode("[")', "E474:")
- call assert_fails('call jsdecode("[1")', "E474:")
- call assert_fails('call jsdecode("[1,")', "E474:")
- call assert_fails('call jsdecode("[1 2]")', "E474:")
-
- call assert_equal(s:varl5, jsdecode(s:jsl5))
+ call assert_equal(s:varl1, js_decode(s:jsonl1))
+ call assert_equal(s:varl2x, js_decode(s:jsonl2))
+ call assert_equal(s:varl2x, js_decode(s:jsonl2s))
+ call assert_equal(s:varl3, js_decode(s:jsonl3))
+
+ call assert_equal(s:vard1, js_decode(s:jsond1))
+ call assert_equal(s:vard1, js_decode(s:jsd1))
+ call assert_equal(s:vard2x, js_decode(s:jsond2))
+ call assert_equal(s:vard2x, js_decode(s:jsd2))
+ call assert_equal(s:vard2x, js_decode(s:jsond2s))
+ call assert_equal(s:vard2x, js_decode(s:jsd2s))
+ call assert_equal(s:vard3, js_decode(s:jsond3))
+ call assert_equal(s:vard3, js_decode(s:jsd3))
+ call assert_equal(s:vard4x, js_decode(s:jsond4))
+ call assert_equal(s:vard4x, js_decode(s:jsd4))
+
+ call assert_equal(s:varvals, js_decode(s:jsonvals))
+
+ call assert_equal(v:true, js_decode('true'))
+ call assert_equal(type(v:true), type(js_decode('true')))
+ call assert_equal(v:none, js_decode(''))
+ call assert_equal(type(v:none), type(js_decode('')))
+ call assert_equal("", js_decode('""'))
+
+ call assert_equal({'n': 1}, js_decode('{"n":1,}'))
+
+ call assert_fails('call js_decode("\"")', "E474:")
+ call assert_fails('call js_decode("blah")', "E474:")
+ call assert_fails('call js_decode("true blah")', "E474:")
+ call assert_fails('call js_decode("<foobar>")', "E474:")
+
+ call assert_fails('call js_decode("{")', "E474:")
+ call assert_fails('call js_decode("{foobar}")', "E474:")
+ call assert_fails('call js_decode("{\"n\",")', "E474:")
+ call assert_fails('call js_decode("{\"n\":")', "E474:")
+ call assert_fails('call js_decode("{\"n\":1")', "E474:")
+ call assert_fails('call js_decode("{\"n\":1,")', "E474:")
+ call assert_fails('call js_decode("{\"n\",1}")', "E474:")
+ call assert_fails('call js_decode("{-}")', "E474:")
+
+ call assert_fails('call js_decode("[foobar]")', "E474:")
+ call assert_fails('call js_decode("[")', "E474:")
+ call assert_fails('call js_decode("[1")', "E474:")
+ call assert_fails('call js_decode("[1,")', "E474:")
+ call assert_fails('call js_decode("[1 2]")', "E474:")
+
+ call assert_equal(s:varl5, js_decode(s:jsl5))
endfunc