Mercurial > vim
comparison src/testdir/test_listdict.vim @ 27859:3cb1a109e987 v8.2.4455
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Commit: https://github.com/vim/vim/commit/2007dd49f5cb36f944cab1cfbceb0f864e625f74
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 23 13:17:47 2022 +0000
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Problem: Accepting one and zero for the second sort() argument is strange.
Solution: Disallow using one and zero in Vim9 script.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 23 Feb 2022 14:30:03 +0100 |
parents | 86e8c92c3f65 |
children | b96409b84eaf |
comparison
equal
deleted
inserted
replaced
27858:6197d182d707 | 27859:3cb1a109e987 |
---|---|
947 | 947 |
948 LET l = [7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four'] | 948 LET l = [7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four'] |
949 call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n')) | 949 call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n')) |
950 | 950 |
951 LET l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []] | 951 LET l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []] |
952 call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 1)) | 952 call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) |
953 call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) | 953 call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) |
954 call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l))) | 954 call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l))) |
955 endif | 955 endif |
956 END | 956 END |
957 call v9.CheckLegacyAndVim9Success(lines) | 957 call v9.CheckLegacyAndVim9Success(lines) |
959 call assert_fails('call reverse("")', 'E899:') | 959 call assert_fails('call reverse("")', 'E899:') |
960 call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:') | 960 call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:') |
961 call assert_fails("call sort([1, 2], function('min'), 1)", "E715:") | 961 call assert_fails("call sort([1, 2], function('min'), 1)", "E715:") |
962 call assert_fails("call sort([1, 2], function('invalid_func'))", "E700:") | 962 call assert_fails("call sort([1, 2], function('invalid_func'))", "E700:") |
963 call assert_fails("call sort([1, 2], function('min'))", "E118:") | 963 call assert_fails("call sort([1, 2], function('min'))", "E118:") |
964 | |
965 let lines =<< trim END | |
966 call sort(['a', 'b'], 0) | |
967 END | |
968 call v9.CheckDefAndScriptFailure(lines, 'E1256: String or function required for argument 2') | |
969 | |
970 let lines =<< trim END | |
971 call sort(['a', 'b'], 1) | |
972 END | |
973 call v9.CheckDefAndScriptFailure(lines, 'E1256: String or function required for argument 2') | |
964 endfunc | 974 endfunc |
965 | 975 |
966 " reduce a list, blob or string | 976 " reduce a list, blob or string |
967 func Test_reduce() | 977 func Test_reduce() |
968 let lines =<< trim END | 978 let lines =<< trim END |