summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-01-23 21:59:52 +0100
committerBram Moolenaar <Bram@vim.org>2016-01-23 21:59:52 +0100
commitf95534c3d411084d1b6112fe64f6108bf7acbb92 (patch)
tree134e2aca8625173143e2e97d378ee48cb960929f /src
parent2dedb45260604911035cff2364aca90a69156ed9 (diff)
downloadvim-f95534c3d411084d1b6112fe64f6108bf7acbb92.zip
patch 7.4.1157
Problem: type() does not work for v:true, v:none, etc. Solution: Add new type numbers.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c7
-rw-r--r--src/testdir/test_json.vim14
-rw-r--r--src/testdir/test_viml.vim17
-rw-r--r--src/version.c2
4 files changed, 40 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index c41e4a55a..7edae3914 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -20157,6 +20157,13 @@ f_type(argvars, rettv)
#ifdef FEAT_FLOAT
case VAR_FLOAT: n = 5; break;
#endif
+ case VAR_SPECIAL:
+ if (argvars[0].vval.v_number == VVAL_FALSE
+ || argvars[0].vval.v_number == VVAL_TRUE)
+ n = 6;
+ else
+ n = 7;
+ break;
default: EMSG2(_(e_intern2), "f_type()"); n = 0; break;
}
rettv->vval.v_number = n;
diff --git a/src/testdir/test_json.vim b/src/testdir/test_json.vim
index e658c9778..b30647947 100644
--- a/src/testdir/test_json.vim
+++ b/src/testdir/test_json.vim
@@ -88,4 +88,18 @@ func Test_decode()
call assert_equal(s:vard2x, jsondecode(s:jsond2))
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_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("{foobar}")', "E474:")
endfunc
diff --git a/src/testdir/test_viml.vim b/src/testdir/test_viml.vim
index 07286fb02..39c0667b8 100644
--- a/src/testdir/test_viml.vim
+++ b/src/testdir/test_viml.vim
@@ -922,6 +922,23 @@ func Test_curlies()
endfunc
"-------------------------------------------------------------------------------
+" Test 91: using type(). {{{1
+"-------------------------------------------------------------------------------
+
+func Test_type()
+ call assert_equal(0, type(0))
+ call assert_equal(1, type(""))
+ call assert_equal(2, type(function("tr")))
+ call assert_equal(3, type([]))
+ call assert_equal(4, type({}))
+ call assert_equal(5, type(0.0))
+ call assert_equal(6, type(v:false))
+ call assert_equal(6, type(v:true))
+ call assert_equal(7, type(v:none))
+ call assert_equal(7, type(v:null))
+endfunc
+
+"-------------------------------------------------------------------------------
" Modelines {{{1
" vim: ts=8 sw=4 tw=80 fdm=marker
" vim: fdt=substitute(substitute(foldtext(),\ '\\%(^+--\\)\\@<=\\(\\s*\\)\\(.\\{-}\\)\:\ \\%(\"\ \\)\\=\\(Test\ \\d*\\)\:\\s*',\ '\\3\ (\\2)\:\ \\1',\ \"\"),\ '\\(Test\\s*\\)\\(\\d\\)\\D\\@=',\ '\\1\ \\2',\ "")
diff --git a/src/version.c b/src/version.c
index d646665c9..2c9911057 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1157,
+/**/
1156,
/**/
1155,