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