patch 8.1.2035: recognizing octal numbers is confusing
Problem: Recognizing octal numbers is confusing.
Solution: Introduce scriptversion 4: do not use octal and allow for single
quote inside numbers.
diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim
index b518f5a..720f309 100644
--- a/src/testdir/test_eval_stuff.vim
+++ b/src/testdir/test_eval_stuff.vim
@@ -74,7 +74,7 @@
new
call setline(1, ['one', 'two', 'three'])
setlocal ff=dos
- write XReadfile
+ silent write XReadfile
let lines = 'XReadfile'->readfile()
call assert_equal(['one', 'two', 'three'], lines)
let lines = readfile('XReadfile', '', 2)
@@ -124,6 +124,15 @@
call assert_equal('ab', a)
endfunc
+" Test fix for issue #4507
+func Test_skip_after_throw()
+ try
+ throw 'something'
+ let x = wincol() || &ts
+ catch /something/
+ endtry
+endfunc
+
scriptversion 2
func Test_string_concat_scriptversion2()
call assert_true(has('vimscript-2'))
@@ -183,17 +192,23 @@
call assert_true(1 && l:x.foo)
endfunc
-func Test_scriptversion()
+scriptversion 4
+func Test_vvar_scriptversion4()
+ call assert_equal(17, 017)
+ call assert_equal(18, 018)
+ call assert_equal(64, 0b1'00'00'00)
+ call assert_equal(1048576, 0x10'00'00)
+ call assert_equal(1000000, 1'000'000)
+endfunc
+
+scriptversion 1
+func Test_vvar_scriptversion1()
+ call assert_equal(15, 017)
+ call assert_equal(18, 018)
+endfunc
+
+func Test_scriptversion_fail()
call writefile(['scriptversion 9'], 'Xversionscript')
call assert_fails('source Xversionscript', 'E999:')
call delete('Xversionscript')
endfunc
-
-" Test fix for issue #4507
-func Test_skip_after_throw()
- try
- throw 'something'
- let x = wincol() || &ts
- catch /something/
- endtry
-endfunc
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 2e051bb..e782061 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -157,6 +157,12 @@
call assert_equal(11259375, str2nr('0XABCDEF', 16))
call assert_equal(-11259375, str2nr('-0xABCDEF', 16))
+ call assert_equal(1, str2nr("1'000'000", 10, 0))
+ call assert_equal(256, str2nr("1'0000'0000", 2, 1))
+ call assert_equal(262144, str2nr("1'000'000", 8, 1))
+ call assert_equal(1000000, str2nr("1'000'000", 10, 1))
+ call assert_equal(65536, str2nr("1'00'00", 16, 1))
+
call assert_equal(0, str2nr('0x10'))
call assert_equal(0, str2nr('0b10'))
call assert_equal(1, str2nr('12', 2))