]> gitweb.factorcode.org Git - factor.git/blob - basis/validators/validators-tests.factor
factor: Retrying on the unit tests. Also normalize some syntax with FUNCTION:.
[factor.git] / basis / validators / validators-tests.factor
1 IN: validators.tests
2 USING: kernel sequences tools.test validators accessors
3 namespaces assocs ;
4
5 { t } [ "on" v-checkbox ] unit-test
6 { f } [ "off" v-checkbox ] unit-test
7
8 { "default test" } [ "" "default test" v-default ] unit-test
9 { "blah" } [ "blah" "default test" v-default ] unit-test
10
11 [ "foo" v-number ] must-fail
12 { 123 } [ "123" v-number ] unit-test
13 { 123 } [ "123" v-integer ] unit-test
14
15 [ "1.0" v-integer ] [ "must be an integer" = ] must-fail-with
16
17 { "slava@factorcode.org" } [
18     "slava@factorcode.org" v-email
19 ] unit-test
20
21 { "slava+foo@factorcode.org" } [
22     "slava+foo@factorcode.org" v-email
23 ] unit-test
24
25 [ "slava@factorcode.o" v-email ]
26 [ "invalid e-mail" = ] must-fail-with
27
28 [ "sla@@factorcode.o" v-email ]
29 [ "invalid e-mail" = ] must-fail-with
30
31 [ "slava@factorcodeorg" v-email ]
32 [ "invalid e-mail" = ] must-fail-with
33
34 { "http://www.factorcode.org" }
35 [ "http://www.factorcode.org" v-url ] unit-test
36
37 [ "http:/www.factorcode.org" v-url ]
38 [ "invalid URL" = ] must-fail-with
39
40 [ "" v-one-line ] must-fail
41 { "hello world" } [ "hello world" v-one-line ] unit-test
42 [ "hello\nworld" v-one-line ] must-fail
43
44 [ "" v-one-word ] must-fail
45 { "hello" } [ "hello" v-one-word ] unit-test
46 [ "hello world" v-one-word ] must-fail
47
48 { 4561261212345467 } [ "4561261212345467" v-credit-card ] unit-test
49
50 { 4561261212345467 } [ "4561-2612-1234-5467" v-credit-card ] unit-test
51
52 { 0 } [ "0000000000000000" v-credit-card ] unit-test
53
54 [ "000000000" v-credit-card ] must-fail
55
56 [ "0000000000000000000000000" v-credit-card ] must-fail
57
58 [ "4561_2612_1234_5467" v-credit-card ] must-fail
59
60 [ "4561-2621-1234-5467" v-credit-card ] must-fail
61
62 { t } [ "http://double.co.nz/w?v=foo" dup v-url = ] unit-test