Mercurial > vim
annotate src/testdir/test_assert.vim @ 8635:3a38d465f731 v7.4.1607
commit https://github.com/vim/vim/commit/f0e86a0dbddc18568910e9e4aaae0cd88ca8087a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 19 19:38:12 2016 +0100
patch 7.4.1607
Problem: Comparing a function that exists on two dicts is not backwards
compatible. (Thinca)
Solution: Only compare the function, not what the partial adds.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 19 Mar 2016 19:45:05 +0100 |
parents | 7d3548ae729d |
children | 65a5a18d3acf |
rev | line source |
---|---|
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test that the methods used for testing work. |
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
3 func Test_assert_false() |
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
4 call assert_false(0) |
7951
03e716299680
commit https://github.com/vim/vim/commit/3712792637516aea7acf76a11533be1066952820
Christian Brabandt <cb@256bit.org>
parents:
7852
diff
changeset
|
5 call assert_false(v:false) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 endfunc |
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
8 func Test_assert_true() |
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
9 call assert_true(1) |
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
10 call assert_true(123) |
7951
03e716299680
commit https://github.com/vim/vim/commit/3712792637516aea7acf76a11533be1066952820
Christian Brabandt <cb@256bit.org>
parents:
7852
diff
changeset
|
11 call assert_true(v:true) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endfunc |
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
14 func Test_assert_equal() |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 let s = 'foo' |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
16 call assert_equal('foo', s) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 let n = 4 |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
18 call assert_equal(4, n) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 let l = [1, 2, 3] |
7279
b5e9810b389d
commit https://github.com/vim/vim/commit/683fa185a4b4ed7595e5942901548b8239ed5cdb
Christian Brabandt <cb@256bit.org>
parents:
7277
diff
changeset
|
20 call assert_equal([1, 2, 3], l) |
7277
6600871bb38c
commit https://github.com/vim/vim/commit/43345546ae63710441f066648b8485fb545b3801
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 endfunc |
7412
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
22 |
7675
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
23 func Test_assert_exception() |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
24 try |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
25 nocommand |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
26 catch |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
27 call assert_exception('E492:') |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
28 endtry |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
29 |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
30 try |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
31 nocommand |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
32 catch |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
33 try |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
34 " illegal argument, get NULL for error |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
35 call assert_exception([]) |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
36 catch |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
37 call assert_exception('E730:') |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
38 endtry |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
39 endtry |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
40 endfunc |
eb9cc96138a3
commit https://github.com/vim/vim/commit/da5dcd936656f524dd0ae7cb2685245f07f5720f
Christian Brabandt <cb@256bit.org>
parents:
7412
diff
changeset
|
41 |
7852
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
42 func Test_wrong_error_type() |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
43 let save_verrors = v:errors |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
44 let v:['errors'] = {'foo': 3} |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
45 call assert_equal('yes', 'no') |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
46 let verrors = v:errors |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
47 let v:errors = save_verrors |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
48 call assert_equal(type([]), type(verrors)) |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
49 endfunc |
8818755d8326
commit https://github.com/vim/vim/commit/a542c680a8b42cb766e64d4ee7374ef4dacb7832
Christian Brabandt <cb@256bit.org>
parents:
7675
diff
changeset
|
50 |
8550
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
51 func Test_compare_fail() |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
52 let s:v = {} |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
53 let s:x = {"a": s:v} |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
54 let s:v["b"] = s:x |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
55 let s:w = {"c": s:x, "d": ''} |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
56 try |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
57 call assert_equal(s:w, '') |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
58 catch |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
59 call assert_exception('E724:') |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
60 call assert_true(v:errors[0] =~ "Expected NULL but got ''") |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
61 call remove(v:errors, 0) |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
62 endtry |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
63 endfunc |
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
64 |
8554
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
65 func Test_assert_fail_fails() |
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
66 call assert_fails('xxx', {}) |
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
67 call assert_true(v:errors[0] =~ "Expected {} but got 'E731:") |
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
68 call remove(v:errors, 0) |
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
69 endfunc |
7d3548ae729d
commit https://github.com/vim/vim/commit/1abb502635c7f317e05a0cf3ea067101f9d684f5
Christian Brabandt <cb@256bit.org>
parents:
8550
diff
changeset
|
70 |
8550
56d0eb96c25a
commit https://github.com/vim/vim/commit/f1551964448607f8222de2d8f0992ea43eb2fe67
Christian Brabandt <cb@256bit.org>
parents:
7951
diff
changeset
|
71 |
7412
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
72 func Test_user_is_happy() |
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
73 smile |
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
74 sleep 300m |
bc5de65e499a
commit https://github.com/vim/vim/commit/2d820808cda15b3ad9fe674393d1f1e997453d9e
Christian Brabandt <cb@256bit.org>
parents:
7279
diff
changeset
|
75 endfunc |