Patch 7.4.1164
Problem:    No tests for comparing special variables.  Error in jsondecode()
            not reported.  test_json does not work Japanse system.
Solution:   Set scriptencoding. (Ken Takata) Add a few more tests. Add error.
Files:      src/json.c, src/testdir/test_viml.vim, src/testdir/test_json.vim


*** ../vim-7.4.1163/src/json.c  2016-01-23 22:51:02.748141627 +0100
--- src/json.c  2016-01-24 14:52:45.699652418 +0100
***************
*** 220,226 ****
      listitem_T        *li;
  
      if (rettv_list_alloc(res) == FAIL)
!       goto fail;
      ++reader->js_used; /* consume the '[' */
  
      while (TRUE)
--- 220,226 ----
      listitem_T        *li;
  
      if (rettv_list_alloc(res) == FAIL)
!       goto failsilent;
      ++reader->js_used; /* consume the '[' */
  
      while (TRUE)
***************
*** 253,258 ****
--- 253,260 ----
            goto fail;
      }
  fail:
+     EMSG(_(e_invarg));
+ failsilent:
      res->v_type = VAR_SPECIAL;
      res->vval.v_number = VVAL_NONE;
  }
***************
*** 268,274 ****
      char_u    *key;
  
      if (rettv_dict_alloc(res) == FAIL)
!       goto fail;
      ++reader->js_used; /* consume the '{' */
  
      while (TRUE)
--- 270,276 ----
      char_u    *key;
  
      if (rettv_dict_alloc(res) == FAIL)
!       goto failsilent;
      ++reader->js_used; /* consume the '{' */
  
      while (TRUE)
***************
*** 293,299 ****
            if (key != NULL)
                EMSG(_(e_emptykey));
            clear_tv(&tvkey);
!           goto fail;
        }
  
        json_skip_white(reader);
--- 295,301 ----
            if (key != NULL)
                EMSG(_(e_emptykey));
            clear_tv(&tvkey);
!           goto failsilent;
        }
  
        json_skip_white(reader);
***************
*** 329,334 ****
--- 331,338 ----
            goto fail;
      }
  fail:
+     EMSG(_(e_invarg));
+ failsilent:
      res->v_type = VAR_SPECIAL;
      res->vval.v_number = VVAL_NONE;
  }
*** ../vim-7.4.1163/src/testdir/test_viml.vim   2016-01-24 14:22:06.282648939 
+0100
--- src/testdir/test_viml.vim   2016-01-24 14:42:55.001744494 +0100
***************
*** 946,951 ****
--- 946,963 ----
      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
  
  
"-------------------------------------------------------------------------------
*** ../vim-7.4.1163/src/testdir/test_json.vim   2016-01-23 21:59:47.569792161 
+0100
--- src/testdir/test_json.vim   2016-01-24 15:00:48.486720414 +0100
***************
*** 1,4 ****
--- 1,5 ----
  " Test for JSON functions.
+ scriptencoding utf-8
  
  let s:json1 = '"str\"in\\g"'
  let s:var1 = "str\"in\\g"
***************
*** 95,105 ****
    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
--- 96,120 ----
    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:")
  endfunc
*** ../vim-7.4.1163/src/version.c       2016-01-24 14:22:06.282648939 +0100
--- src/version.c       2016-01-24 14:42:01.018302541 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     1164,
  /**/

-- 
Tips for aliens in New York: Land anywhere.  Central Park, anywhere.
No one will care or indeed even notice.
                -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui