Mercurial > vim
comparison src/testdir/test_digraph.vim @ 25759:ea0820d05257 v8.2.3415
patch 8.2.3415: Vim9: not all function argument types are properly checked
Commit: https://github.com/vim/vim/commit/fc3b775055c2361e507a1a44008d5a7d37eecf14
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Sep 8 14:57:42 2021 +0200
patch 8.2.3415: Vim9: not all function argument types are properly checked
Problem: Vim9: Not all function argument types are properly checked.
Solution: Add and improve argument type checks. (Yegappan Lakshmanan,
closes #8839)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 08 Sep 2021 15:00:05 +0200 |
parents | 6b711b01f2ca |
children | b4c111ea83b1 |
comparison
equal
deleted
inserted
replaced
25758:fe9fee93ea71 | 25759:ea0820d05257 |
---|---|
534 call assert_fails('call digraph_set("aaa", "あ")', 'E1214: Digraph must be just two characters: aaa') | 534 call assert_fails('call digraph_set("aaa", "あ")', 'E1214: Digraph must be just two characters: aaa') |
535 call assert_fails('call digraph_set("b", "あ")', 'E1214: Digraph must be just two characters: b') | 535 call assert_fails('call digraph_set("b", "あ")', 'E1214: Digraph must be just two characters: b') |
536 call assert_fails('call digraph_set("あ", "あ")', 'E1214: Digraph must be just two characters: あ') | 536 call assert_fails('call digraph_set("あ", "あ")', 'E1214: Digraph must be just two characters: あ') |
537 call assert_fails('call digraph_set("aa", "ああ")', 'E1215: Digraph must be one character: ああ') | 537 call assert_fails('call digraph_set("aa", "ああ")', 'E1215: Digraph must be one character: ああ') |
538 call assert_fails('call digraph_set("aa", "か" .. nr2char(0x3099))', 'E1215: Digraph must be one character: か' .. nr2char(0x3099)) | 538 call assert_fails('call digraph_set("aa", "か" .. nr2char(0x3099))', 'E1215: Digraph must be one character: か' .. nr2char(0x3099)) |
539 call assert_fails('call digraph_set(test_null_string(), "い")', 'E1214: Digraph must be just two characters') | |
540 call assert_fails('call digraph_set("aa", 0z10)', 'E976: Using a Blob as a String') | |
539 bwipe! | 541 bwipe! |
540 endfunc | 542 endfunc |
541 | 543 |
542 func Test_digraph_get_function() | 544 func Test_digraph_get_function() |
543 " Built-in digraphs | 545 " Built-in digraphs |
551 call assert_equal('あ', 'aa'->digraph_get()) | 553 call assert_equal('あ', 'aa'->digraph_get()) |
552 call assert_equal('い', digraph_get(' i')) | 554 call assert_equal('い', digraph_get(' i')) |
553 call assert_equal('う', digraph_get(' ')) | 555 call assert_equal('う', digraph_get(' ')) |
554 call assert_fails('call digraph_get("aaa")', 'E1214: Digraph must be just two characters: aaa') | 556 call assert_fails('call digraph_get("aaa")', 'E1214: Digraph must be just two characters: aaa') |
555 call assert_fails('call digraph_get("b")', 'E1214: Digraph must be just two characters: b') | 557 call assert_fails('call digraph_get("b")', 'E1214: Digraph must be just two characters: b') |
558 call assert_fails('call digraph_get(test_null_string())', 'E1214: Digraph must be just two characters:') | |
559 call assert_fails('call digraph_get(0z10)', 'E976: Using a Blob as a String') | |
556 endfunc | 560 endfunc |
557 | 561 |
558 func Test_digraph_get_function_encode() | 562 func Test_digraph_get_function_encode() |
559 CheckFeature iconv | 563 CheckFeature iconv |
560 | 564 |
574 call digraph_setlist([['aa', 'き'], ['bb', 'く']]) | 578 call digraph_setlist([['aa', 'き'], ['bb', 'く']]) |
575 call assert_equal('き', digraph_get('aa')) | 579 call assert_equal('き', digraph_get('aa')) |
576 call assert_equal('く', digraph_get('bb')) | 580 call assert_equal('く', digraph_get('bb')) |
577 | 581 |
578 call assert_fails('call digraph_setlist([[]])', 'E1216:') | 582 call assert_fails('call digraph_setlist([[]])', 'E1216:') |
579 call assert_fails('call digraph_setlist([["aa", "b", "cc"]])', '1216:') | 583 call assert_fails('call digraph_setlist([["aa", "b", "cc"]])', 'E1216:') |
580 call assert_fails('call digraph_setlist([["あ", "あ"]])', 'E1214: Digraph must be just two characters: あ') | 584 call assert_fails('call digraph_setlist([["あ", "あ"]])', 'E1214: Digraph must be just two characters: あ') |
585 call assert_fails('call digraph_setlist([test_null_list()])', 'E1216:') | |
586 call assert_fails('call digraph_setlist({})', 'E1216:') | |
587 call assert_fails('call digraph_setlist([{}])', 'E1216:') | |
588 call assert_true(digraph_setlist(test_null_list())) | |
581 endfunc | 589 endfunc |
582 | 590 |
583 func Test_digraph_getlist_function() | 591 func Test_digraph_getlist_function() |
584 " Make sure user-defined digraphs are defined | 592 " Make sure user-defined digraphs are defined |
585 call digraph_setlist([['aa', 'き'], ['bb', 'く']]) | 593 call digraph_setlist([['aa', 'き'], ['bb', 'く']]) |
590 | 598 |
591 " We don't know how many digraphs are registered before, so check the number | 599 " We don't know how many digraphs are registered before, so check the number |
592 " of digraphs returned. | 600 " of digraphs returned. |
593 call assert_equal(digraph_getlist()->len(), digraph_getlist(0)->len()) | 601 call assert_equal(digraph_getlist()->len(), digraph_getlist(0)->len()) |
594 call assert_notequal((digraph_getlist()->len()), digraph_getlist(1)->len()) | 602 call assert_notequal((digraph_getlist()->len()), digraph_getlist(1)->len()) |
603 | |
604 call assert_fails('call digraph_getlist(0z12)', 'E974: Using a Blob as a Number') | |
595 endfunc | 605 endfunc |
596 | 606 |
597 | 607 |
598 " vim: shiftwidth=2 sts=2 expandtab | 608 " vim: shiftwidth=2 sts=2 expandtab |