PageRenderTime 18ms CodeModel.GetById 15ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/red-system/tests/source/units/not-test.reds

http://github.com/dockimbel/Red
Unknown | 65 lines | 49 code | 16 blank | 0 comment | 0 complexity | 84b73dab1fa3cd2507e6a65184d6d62d MD5 | raw file
 1Red/System [
 2	Title:   "Red/System NOT function test script"
 3	Author:  "Nenad Rakocevic"
 4	File: 	 %not-test.reds
 5	Rights:  "Copyright (C) 2011 Nenad Rakocevic. All rights reserved."
 6	License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
 7]
 8
 9#include %../../../../quick-test/quick-test.reds
10
11not-foo: func [a [logic!] return: [logic!]][a]
12not-nfoo: func [a [logic!] return: [logic!]][not a]
13
14~~~start-file~~~ "not"
15
16  --test-- "not-1" --assert false = not true
17  --test-- "not-2" --assert not false
18  --test-- "not-3" --assert not not true
19  --test-- "not-4" --assert false = not not false
20
21  --test-- "not-5"
22    n-logic-a: true
23  --assert false = not n-logic-a
24
25  --test-- "not-6"
26    n-logic-a: false
27  --assert not n-logic-a
28
29  --test-- "not-7" --assert false = not not-foo true
30  --test-- "not-8" --assert not not-foo false
31  --test-- "not-9" --assert false = not-foo not true
32  --test-- "not-10" --assert not-foo not false
33
34  --test-- "not-11"
35    n-logic-a: true
36  --assert false = not not-foo n-logic-a
37  
38  --test-- "not-12"
39    n-logic-a: true
40  --assert false = not-foo not n-logic-a
41
42  --test-- "not-13"
43    n-logic-a: false
44  --assert not not-foo n-logic-a 
45
46  --test-- "not-14"
47    n-logic-a: false
48  --assert not not-foo n-logic-a
49
50  --test-- "not-15" --assert false = not-nfoo true
51  --test-- "not-16" --assert not-nfoo false
52
53  --test-- "not-17" --assert false = not-nfoo true
54  --test-- "not-18" --assert not-nfoo false
55  
56  --test-- "not-19" --assert -1 = (not 4 and 3)
57  --test-- "not-20" --assert -5 = not 4
58  --test-- "not-21" --assert 3 = (-5 and 3)
59  --test-- "not-22" --assert 3 = (3 and -5)
60  --test-- "not-23" --assert 3 = (3 and not 4)
61  --test-- "not-24" --assert 0 = (4 and 3)
62
63~~~end-file~~~
64
65;TBD: write unit tests for bitwise NOT on integer