To: vim_dev@googlegroups.com Subject: Patch 7.4.1157 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1157 Problem: type() does not work for v:true, v:none, etc. Solution: Add new type numbers. Files: src/eval.c, src/testdir/test_json.vim, src/testdir/test_viml.vim *** ../vim-7.4.1156/src/eval.c 2016-01-23 19:54:26.445549280 +0100 --- src/eval.c 2016-01-23 21:49:20.188498681 +0100 *************** *** 20157,20162 **** --- 20157,20169 ---- #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; *** ../vim-7.4.1156/src/testdir/test_json.vim 2016-01-23 19:45:48.626931291 +0100 --- src/testdir/test_json.vim 2016-01-23 21:54:52.136955206 +0100 *************** *** 88,91 **** --- 88,105 ---- 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("")', "E474:") + call assert_fails('call jsondecode("[foobar]")', "E474:") + call assert_fails('call jsondecode("{foobar}")', "E474:") endfunc *** ../vim-7.4.1156/src/testdir/test_viml.vim 2016-01-17 14:58:43.239669122 +0100 --- src/testdir/test_viml.vim 2016-01-23 21:45:12.787142950 +0100 *************** *** 922,927 **** --- 922,944 ---- 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',\ "") *** ../vim-7.4.1156/src/version.c 2016-01-23 21:38:47.755264319 +0100 --- src/version.c 2016-01-23 21:57:00.495586296 +0100 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 1157, /**/ -- How To Keep A Healthy Level Of Insanity: 11. Specify that your drive-through order is "to go". /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///