Mercurial > vim
comparison src/testdir/test_expr.vim @ 27457:4c16acb2525f v8.2.4257
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Commit: https://github.com/vim/vim/commit/62aec93bfdb9e1b40d03a6d2e8e9511f8b1bdb2d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 29 21:45:34 2022 +0000
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Problem: Vim9: finding global function without g: prefix but not finding
global variable is inconsistent.
Solution: Require using g: for a global function. Change the vim9.vim
script into a Vim9 script with exports. Fix that import in legacy
script does not work.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 29 Jan 2022 23:00:05 +0100 |
parents | 31c23760d590 |
children | fb4c30606b4a |
comparison
equal
deleted
inserted
replaced
27456:a8e2d91995ce | 27457:4c16acb2525f |
---|---|
1 " Tests for expressions. | 1 " Tests for expressions. |
2 | 2 |
3 source check.vim | 3 source check.vim |
4 source vim9.vim | 4 import './vim9.vim' as v9 |
5 | 5 |
6 func Test_equal() | 6 func Test_equal() |
7 let base = {} | 7 let base = {} |
8 func base.method() | 8 func base.method() |
9 return 1 | 9 return 1 |
49 call assert_equal('no', 0 ? 'yes' : 'no') | 49 call assert_equal('no', 0 ? 'yes' : 'no') |
50 | 50 |
51 call assert_fails('echo [1] ? "yes" : "no"', 'E745:') | 51 call assert_fails('echo [1] ? "yes" : "no"', 'E745:') |
52 call assert_fails('echo {} ? "yes" : "no"', 'E728:') | 52 call assert_fails('echo {} ? "yes" : "no"', 'E728:') |
53 END | 53 END |
54 call CheckLegacyAndVim9Success(lines) | 54 call v9.CheckLegacyAndVim9Success(lines) |
55 | 55 |
56 call assert_equal('no', 'x' ? 'yes' : 'no') | 56 call assert_equal('no', 'x' ? 'yes' : 'no') |
57 call CheckDefAndScriptFailure(["'x' ? 'yes' : 'no'"], 'E1135:') | 57 call v9.CheckDefAndScriptFailure(["'x' ? 'yes' : 'no'"], 'E1135:') |
58 call assert_equal('yes', '1x' ? 'yes' : 'no') | 58 call assert_equal('yes', '1x' ? 'yes' : 'no') |
59 call CheckDefAndScriptFailure(["'1x' ? 'yes' : 'no'"], 'E1135:') | 59 call v9.CheckDefAndScriptFailure(["'1x' ? 'yes' : 'no'"], 'E1135:') |
60 endfunc | 60 endfunc |
61 | 61 |
62 func Test_op_falsy() | 62 func Test_op_falsy() |
63 let lines =<< trim END | 63 let lines =<< trim END |
64 call assert_equal(v:true, v:true ?? 456) | 64 call assert_equal(v:true, v:true ?? 456) |
79 call assert_equal(456, {} ?? 456) | 79 call assert_equal(456, {} ?? 456) |
80 if has('float') | 80 if has('float') |
81 call assert_equal(456, 0.0 ?? 456) | 81 call assert_equal(456, 0.0 ?? 456) |
82 endif | 82 endif |
83 END | 83 END |
84 call CheckLegacyAndVim9Success(lines) | 84 call v9.CheckLegacyAndVim9Success(lines) |
85 endfunc | 85 endfunc |
86 | 86 |
87 func Test_dict() | 87 func Test_dict() |
88 let lines =<< trim END | 88 let lines =<< trim END |
89 VAR d = {'': 'empty', 'a': 'a', 0: 'zero'} | 89 VAR d = {'': 'empty', 'a': 'a', 0: 'zero'} |
99 call assert_equal('aaa', d['a']) | 99 call assert_equal('aaa', d['a']) |
100 | 100 |
101 LET d[ 'b' ] = 'bbb' | 101 LET d[ 'b' ] = 'bbb' |
102 call assert_equal('bbb', d[ 'b' ]) | 102 call assert_equal('bbb', d[ 'b' ]) |
103 END | 103 END |
104 call CheckLegacyAndVim9Success(lines) | 104 call v9.CheckLegacyAndVim9Success(lines) |
105 | 105 |
106 call CheckLegacyAndVim9Failure(["VAR i = has_key([], 'a')"], ['E715:', 'E1013:', 'E1206:']) | 106 call v9.CheckLegacyAndVim9Failure(["VAR i = has_key([], 'a')"], ['E715:', 'E1013:', 'E1206:']) |
107 endfunc | 107 endfunc |
108 | 108 |
109 func Test_strgetchar() | 109 func Test_strgetchar() |
110 let lines =<< trim END | 110 let lines =<< trim END |
111 call assert_equal(char2nr('a'), strgetchar('axb', 0)) | 111 call assert_equal(char2nr('a'), strgetchar('axb', 0)) |
114 | 114 |
115 call assert_equal(-1, strgetchar('axb', -1)) | 115 call assert_equal(-1, strgetchar('axb', -1)) |
116 call assert_equal(-1, strgetchar('axb', 3)) | 116 call assert_equal(-1, strgetchar('axb', 3)) |
117 call assert_equal(-1, strgetchar('', 0)) | 117 call assert_equal(-1, strgetchar('', 0)) |
118 END | 118 END |
119 call CheckLegacyAndVim9Success(lines) | 119 call v9.CheckLegacyAndVim9Success(lines) |
120 | 120 |
121 call CheckLegacyAndVim9Failure(["VAR c = strgetchar([], 1)"], ['E730:', 'E1013:', 'E1174:']) | 121 call v9.CheckLegacyAndVim9Failure(["VAR c = strgetchar([], 1)"], ['E730:', 'E1013:', 'E1174:']) |
122 call CheckLegacyAndVim9Failure(["VAR c = strgetchar('axb', [])"], ['E745:', 'E1013:', 'E1210:']) | 122 call v9.CheckLegacyAndVim9Failure(["VAR c = strgetchar('axb', [])"], ['E745:', 'E1013:', 'E1210:']) |
123 endfunc | 123 endfunc |
124 | 124 |
125 func Test_strcharpart() | 125 func Test_strcharpart() |
126 let lines =<< trim END | 126 let lines =<< trim END |
127 call assert_equal('a', strcharpart('axb', 0, 1)) | 127 call assert_equal('a', strcharpart('axb', 0, 1)) |
136 | 136 |
137 call assert_equal('a', strcharpart('axb', -1, 2)) | 137 call assert_equal('a', strcharpart('axb', -1, 2)) |
138 | 138 |
139 call assert_equal('edit', "editor"[-10 : 3]) | 139 call assert_equal('edit', "editor"[-10 : 3]) |
140 END | 140 END |
141 call CheckLegacyAndVim9Success(lines) | 141 call v9.CheckLegacyAndVim9Success(lines) |
142 endfunc | 142 endfunc |
143 | 143 |
144 func Test_getreg_empty_list() | 144 func Test_getreg_empty_list() |
145 let lines =<< trim END | 145 let lines =<< trim END |
146 call assert_equal('', getreg('x')) | 146 call assert_equal('', getreg('x')) |
148 VAR x = getreg('x', 1, 1) | 148 VAR x = getreg('x', 1, 1) |
149 VAR y = x | 149 VAR y = x |
150 call add(x, 'foo') | 150 call add(x, 'foo') |
151 call assert_equal(['foo'], y) | 151 call assert_equal(['foo'], y) |
152 END | 152 END |
153 call CheckLegacyAndVim9Success(lines) | 153 call v9.CheckLegacyAndVim9Success(lines) |
154 | 154 |
155 call CheckLegacyAndVim9Failure(['call getreg([])'], ['E730:', 'E1013:', 'E1174:']) | 155 call v9.CheckLegacyAndVim9Failure(['call getreg([])'], ['E730:', 'E1013:', 'E1174:']) |
156 endfunc | 156 endfunc |
157 | 157 |
158 func Test_loop_over_null_list() | 158 func Test_loop_over_null_list() |
159 let lines =<< trim END | 159 let lines =<< trim END |
160 VAR null_list = test_null_list() | 160 VAR null_list = test_null_list() |
161 for i in null_list | 161 for i in null_list |
162 call assert_report('should not get here') | 162 call assert_report('should not get here') |
163 endfor | 163 endfor |
164 END | 164 END |
165 call CheckLegacyAndVim9Success(lines) | 165 call v9.CheckLegacyAndVim9Success(lines) |
166 endfunc | 166 endfunc |
167 | 167 |
168 func Test_setreg_null_list() | 168 func Test_setreg_null_list() |
169 let lines =<< trim END | 169 let lines =<< trim END |
170 call setreg('x', test_null_list()) | 170 call setreg('x', test_null_list()) |
171 END | 171 END |
172 call CheckLegacyAndVim9Success(lines) | 172 call v9.CheckLegacyAndVim9Success(lines) |
173 endfunc | 173 endfunc |
174 | 174 |
175 func Test_special_char() | 175 func Test_special_char() |
176 " The failure is only visible using valgrind. | 176 " The failure is only visible using valgrind. |
177 call CheckLegacyAndVim9Failure(['echo "\<C-">'], ['E15:', 'E1004:', 'E1004:']) | 177 call v9.CheckLegacyAndVim9Failure(['echo "\<C-">'], ['E15:', 'E1004:', 'E1004:']) |
178 endfunc | 178 endfunc |
179 | 179 |
180 func Test_method_with_prefix() | 180 func Test_method_with_prefix() |
181 let lines =<< trim END | 181 let lines =<< trim END |
182 call assert_equal(TRUE, !range(5)->empty()) | 182 call assert_equal(TRUE, !range(5)->empty()) |
183 call assert_equal(FALSE, !-3) | 183 call assert_equal(FALSE, !-3) |
184 END | 184 END |
185 call CheckLegacyAndVim9Success(lines) | 185 call v9.CheckLegacyAndVim9Success(lines) |
186 | 186 |
187 call assert_equal([0, 1, 2], --3->range()) | 187 call assert_equal([0, 1, 2], --3->range()) |
188 call CheckDefAndScriptFailure(['eval --3->range()'], 'E15') | 188 call v9.CheckDefAndScriptFailure(['eval --3->range()'], 'E15') |
189 | 189 |
190 call assert_equal(1, !+-+0) | 190 call assert_equal(1, !+-+0) |
191 call CheckDefAndScriptFailure(['eval !+-+0'], 'E15') | 191 call v9.CheckDefAndScriptFailure(['eval !+-+0'], 'E15') |
192 endfunc | 192 endfunc |
193 | 193 |
194 func Test_option_value() | 194 func Test_option_value() |
195 let lines =<< trim END | 195 let lines =<< trim END |
196 #" boolean | 196 #" boolean |
212 call assert_equal("", &cpo) | 212 call assert_equal("", &cpo) |
213 set cpo=abcdefgi | 213 set cpo=abcdefgi |
214 call assert_equal("abcdefgi", &cpo) | 214 call assert_equal("abcdefgi", &cpo) |
215 set cpo&vim | 215 set cpo&vim |
216 END | 216 END |
217 call CheckLegacyAndVim9Success(lines) | 217 call v9.CheckLegacyAndVim9Success(lines) |
218 endfunc | 218 endfunc |
219 | 219 |
220 func Test_printf_misc() | 220 func Test_printf_misc() |
221 let lines =<< trim END | 221 let lines =<< trim END |
222 call assert_equal('123', printf('123')) | 222 call assert_equal('123', printf('123')) |
405 call assert_equal('[00000あiう]', printf('[%010.7S]', 'あiう')) | 405 call assert_equal('[00000あiう]', printf('[%010.7S]', 'あiう')) |
406 | 406 |
407 call assert_equal('1%', printf('%d%%', 1)) | 407 call assert_equal('1%', printf('%d%%', 1)) |
408 call assert_notequal('', printf('%p', "abc")) | 408 call assert_notequal('', printf('%p', "abc")) |
409 END | 409 END |
410 call CheckLegacyAndVim9Success(lines) | 410 call v9.CheckLegacyAndVim9Success(lines) |
411 | 411 |
412 call CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:") | 412 call v9.CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:") |
413 endfunc | 413 endfunc |
414 | 414 |
415 func Test_printf_float() | 415 func Test_printf_float() |
416 if has('float') | 416 if has('float') |
417 let lines =<< trim END | 417 let lines =<< trim END |
517 call assert_equal('nan', printf('%s', 0.0 / 0.0)) | 517 call assert_equal('nan', printf('%s', 0.0 / 0.0)) |
518 call assert_equal('nan', printf('%s', -0.0 / 0.0)) | 518 call assert_equal('nan', printf('%s', -0.0 / 0.0)) |
519 call assert_equal('nan', printf('%S', 0.0 / 0.0)) | 519 call assert_equal('nan', printf('%S', 0.0 / 0.0)) |
520 call assert_equal('nan', printf('%S', -0.0 / 0.0)) | 520 call assert_equal('nan', printf('%S', -0.0 / 0.0)) |
521 END | 521 END |
522 call CheckLegacyAndVim9Success(lines) | 522 call v9.CheckLegacyAndVim9Success(lines) |
523 | 523 |
524 call CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:') | 524 call v9.CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:') |
525 endif | 525 endif |
526 endfunc | 526 endfunc |
527 | 527 |
528 func Test_printf_errors() | 528 func Test_printf_errors() |
529 call CheckLegacyAndVim9Failure(['echo printf("%d", {})'], 'E728:') | 529 call v9.CheckLegacyAndVim9Failure(['echo printf("%d", {})'], 'E728:') |
530 call CheckLegacyAndVim9Failure(['echo printf("%d", [])'], 'E745:') | 530 call v9.CheckLegacyAndVim9Failure(['echo printf("%d", [])'], 'E745:') |
531 call CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:') | 531 call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:') |
532 call CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:') | 532 call v9.CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:') |
533 call CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:') | 533 call v9.CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:') |
534 if has('float') | 534 if has('float') |
535 call CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:') | 535 call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:') |
536 call CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:') | 536 call v9.CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:') |
537 endif | 537 endif |
538 endfunc | 538 endfunc |
539 | 539 |
540 func Test_printf_64bit() | 540 func Test_printf_64bit() |
541 let lines =<< trim END | 541 let lines =<< trim END |
542 call assert_equal("123456789012345", printf('%d', 123456789012345)) | 542 call assert_equal("123456789012345", printf('%d', 123456789012345)) |
543 END | 543 END |
544 call CheckLegacyAndVim9Success(lines) | 544 call v9.CheckLegacyAndVim9Success(lines) |
545 endfunc | 545 endfunc |
546 | 546 |
547 func Test_printf_spec_s() | 547 func Test_printf_spec_s() |
548 let lines =<< trim END | 548 let lines =<< trim END |
549 #" number | 549 #" number |
569 call assert_equal('printf', printf('%s', 'printf'->function())) | 569 call assert_equal('printf', printf('%s', 'printf'->function())) |
570 | 570 |
571 #" partial | 571 #" partial |
572 call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s']))) | 572 call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s']))) |
573 END | 573 END |
574 call CheckLegacyAndVim9Success(lines) | 574 call v9.CheckLegacyAndVim9Success(lines) |
575 endfunc | 575 endfunc |
576 | 576 |
577 func Test_printf_spec_b() | 577 func Test_printf_spec_b() |
578 let lines =<< trim END | 578 let lines =<< trim END |
579 call assert_equal("0", printf('%b', 0)) | 579 call assert_equal("0", printf('%b', 0)) |
585 call assert_equal("0B01111011", printf('%#010B', 123)) | 585 call assert_equal("0B01111011", printf('%#010B', 123)) |
586 call assert_equal("1001001100101100000001011010010", printf('%b', 1234567890)) | 586 call assert_equal("1001001100101100000001011010010", printf('%b', 1234567890)) |
587 call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345)) | 587 call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345)) |
588 call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1)) | 588 call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1)) |
589 END | 589 END |
590 call CheckLegacyAndVim9Success(lines) | 590 call v9.CheckLegacyAndVim9Success(lines) |
591 endfunc | 591 endfunc |
592 | 592 |
593 func Test_max_min_errors() | 593 func Test_max_min_errors() |
594 call CheckLegacyAndVim9Failure(['call max(v:true)'], ['E712:', 'E1013:', 'E1227:']) | 594 call v9.CheckLegacyAndVim9Failure(['call max(v:true)'], ['E712:', 'E1013:', 'E1227:']) |
595 call CheckLegacyAndVim9Failure(['call max(v:true)'], ['max()', 'E1013:', 'E1227:']) | 595 call v9.CheckLegacyAndVim9Failure(['call max(v:true)'], ['max()', 'E1013:', 'E1227:']) |
596 call CheckLegacyAndVim9Failure(['call min(v:true)'], ['E712:', 'E1013:', 'E1227:']) | 596 call v9.CheckLegacyAndVim9Failure(['call min(v:true)'], ['E712:', 'E1013:', 'E1227:']) |
597 call CheckLegacyAndVim9Failure(['call min(v:true)'], ['min()', 'E1013:', 'E1227:']) | 597 call v9.CheckLegacyAndVim9Failure(['call min(v:true)'], ['min()', 'E1013:', 'E1227:']) |
598 endfunc | 598 endfunc |
599 | 599 |
600 func Test_function_with_funcref() | 600 func Test_function_with_funcref() |
601 let lines =<< trim END | 601 let lines =<< trim END |
602 VAR s:F = function('type') | 602 VAR s:F = function('type') |
613 VAR name = string(s:Len) | 613 VAR name = string(s:Len) |
614 #" can evaluate "function('<lambda>99')" | 614 #" can evaluate "function('<lambda>99')" |
615 call execute('VAR Ref = ' .. name) | 615 call execute('VAR Ref = ' .. name) |
616 call assert_equal(4, Ref('text')) | 616 call assert_equal(4, Ref('text')) |
617 END | 617 END |
618 call CheckTransLegacySuccess(lines) | 618 call v9.CheckTransLegacySuccess(lines) |
619 " cannot create s: variable in :def function | 619 " cannot create s: variable in :def function |
620 call CheckTransVim9Success(lines) | 620 call v9.CheckTransVim9Success(lines) |
621 endfunc | 621 endfunc |
622 | 622 |
623 func Test_funcref() | 623 func Test_funcref() |
624 func! One() | 624 func! One() |
625 return 1 | 625 return 1 |
666 LET exp[0]['conceal'] = '5' | 666 LET exp[0]['conceal'] = '5' |
667 endif | 667 endif |
668 eval set->setmatches() | 668 eval set->setmatches() |
669 call assert_equal(exp, getmatches()) | 669 call assert_equal(exp, getmatches()) |
670 END | 670 END |
671 call CheckLegacyAndVim9Success(lines) | 671 call v9.CheckLegacyAndVim9Success(lines) |
672 | 672 |
673 call CheckLegacyAndVim9Failure(['VAR m = setmatches([], [])'], ['E745:', 'E1013:', 'E1210:']) | 673 call v9.CheckLegacyAndVim9Failure(['VAR m = setmatches([], [])'], ['E745:', 'E1013:', 'E1210:']) |
674 endfunc | 674 endfunc |
675 | 675 |
676 func Test_empty_concatenate() | 676 func Test_empty_concatenate() |
677 let lines =<< trim END | 677 let lines =<< trim END |
678 call assert_equal('b', 'a'[4 : 0] .. 'b') | 678 call assert_equal('b', 'a'[4 : 0] .. 'b') |
679 call assert_equal('b', 'b' .. 'a'[4 : 0]) | 679 call assert_equal('b', 'b' .. 'a'[4 : 0]) |
680 END | 680 END |
681 call CheckLegacyAndVim9Success(lines) | 681 call v9.CheckLegacyAndVim9Success(lines) |
682 endfunc | 682 endfunc |
683 | 683 |
684 func Test_broken_number() | 684 func Test_broken_number() |
685 call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 1X'], 'E15:') | 685 call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 1X'], 'E15:') |
686 call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0b1X'], 'E15:') | 686 call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0b1X'], 'E15:') |
687 call CheckLegacyAndVim9Failure(['echo 0b12'], 'E15:') | 687 call v9.CheckLegacyAndVim9Failure(['echo 0b12'], 'E15:') |
688 call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0x1X'], 'E15:') | 688 call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0x1X'], 'E15:') |
689 call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 011X'], 'E15:') | 689 call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 011X'], 'E15:') |
690 | 690 |
691 call CheckLegacyAndVim9Success(['call assert_equal(2, str2nr("2a"))']) | 691 call v9.CheckLegacyAndVim9Success(['call assert_equal(2, str2nr("2a"))']) |
692 | 692 |
693 call CheckLegacyAndVim9Failure(['inoremap <Char-0b1z> b'], 'E474:') | 693 call v9.CheckLegacyAndVim9Failure(['inoremap <Char-0b1z> b'], 'E474:') |
694 endfunc | 694 endfunc |
695 | 695 |
696 func Test_eval_after_if() | 696 func Test_eval_after_if() |
697 let s:val = '' | 697 let s:val = '' |
698 func SetVal(x) | 698 func SetVal(x) |
781 unlet $X_VIM_TEST_COMPLETE_ENV | 781 unlet $X_VIM_TEST_COMPLETE_ENV |
782 endfunc | 782 endfunc |
783 | 783 |
784 " Test for errors in expression evaluation | 784 " Test for errors in expression evaluation |
785 func Test_expr_eval_error() | 785 func Test_expr_eval_error() |
786 call CheckLegacyAndVim9Failure(["VAR i = 'abc' .. []"], ['E730:', 'E1105:', 'E730:']) | 786 call v9.CheckLegacyAndVim9Failure(["VAR i = 'abc' .. []"], ['E730:', 'E1105:', 'E730:']) |
787 call CheckLegacyAndVim9Failure(["VAR l = [] + 10"], ['E745:', 'E1051:', 'E745']) | 787 call v9.CheckLegacyAndVim9Failure(["VAR l = [] + 10"], ['E745:', 'E1051:', 'E745']) |
788 call CheckLegacyAndVim9Failure(["VAR v = 10 + []"], ['E745:', 'E1051:', 'E745:']) | 788 call v9.CheckLegacyAndVim9Failure(["VAR v = 10 + []"], ['E745:', 'E1051:', 'E745:']) |
789 call CheckLegacyAndVim9Failure(["VAR v = 10 / []"], ['E745:', 'E1036:', 'E745:']) | 789 call v9.CheckLegacyAndVim9Failure(["VAR v = 10 / []"], ['E745:', 'E1036:', 'E745:']) |
790 call CheckLegacyAndVim9Failure(["VAR v = -{}"], ['E728:', 'E1012:', 'E728:']) | 790 call v9.CheckLegacyAndVim9Failure(["VAR v = -{}"], ['E728:', 'E1012:', 'E728:']) |
791 endfunc | 791 endfunc |
792 | 792 |
793 func Test_white_in_function_call() | 793 func Test_white_in_function_call() |
794 let lines =<< trim END | 794 let lines =<< trim END |
795 VAR text = substitute ( 'some text' , 't' , 'T' , 'g' ) | 795 VAR text = substitute ( 'some text' , 't' , 'T' , 'g' ) |
796 call assert_equal('some TexT', text) | 796 call assert_equal('some TexT', text) |
797 END | 797 END |
798 call CheckTransLegacySuccess(lines) | 798 call v9.CheckTransLegacySuccess(lines) |
799 | 799 |
800 let lines =<< trim END | 800 let lines =<< trim END |
801 var text = substitute ( 'some text' , 't' , 'T' , 'g' ) | 801 var text = substitute ( 'some text' , 't' , 'T' , 'g' ) |
802 call assert_equal('some TexT', text) | 802 call assert_equal('some TexT', text) |
803 END | 803 END |
804 call CheckDefAndScriptFailure(lines, ['E1001:', 'E121:']) | 804 call v9.CheckDefAndScriptFailure(lines, ['E1001:', 'E121:']) |
805 endfunc | 805 endfunc |
806 | 806 |
807 " Test for float value comparison | 807 " Test for float value comparison |
808 func Test_float_compare() | 808 func Test_float_compare() |
809 CheckFeature float | 809 CheckFeature float |
823 #" two -inf (infinity) are equal | 823 #" two -inf (infinity) are equal |
824 call assert_true(-(1.0 / 0) == -(2.0 / 0)) | 824 call assert_true(-(1.0 / 0) == -(2.0 / 0)) |
825 #" +infinity != -infinity | 825 #" +infinity != -infinity |
826 call assert_true((1.0 / 0) != -(2.0 / 0)) | 826 call assert_true((1.0 / 0) != -(2.0 / 0)) |
827 END | 827 END |
828 call CheckLegacyAndVim9Success(lines) | 828 call v9.CheckLegacyAndVim9Success(lines) |
829 endfunc | 829 endfunc |
830 | 830 |
831 " vim: shiftwidth=2 sts=2 expandtab | 831 " vim: shiftwidth=2 sts=2 expandtab |