-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.inp
117 lines (101 loc) · 4.92 KB
/
test.inp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Test comments
[#System debug: 3] // Turn on debugging
// Test #Object
[['sam equals: "sam"] assert] // Test quoting
[[['sam instance-of] equals: #String] assert] // Test instance-of, equals:
#Object // Test tostring, print
// Test #Metaclass
[[[#Integer #name] equals: "#Integer"] assert] // Test name
[[[#Integer #parent] equals: #Object] assert] // Test parent
[#Metaclass new: "Test" parent: #Object instance-variables: '(a b c)] // Test sublclassing
[Test instance-variables] // Test instance-variables
[#Environment delete: "Test"]
// Test #Code_Method
[[[[[[#Integer instance-methods] at: "add:"] cdr] eval: (1 2)] equals: 3] assert] // Test eval
// Test #Boolean
[[[[1 equals: 1] tostring] equals: "#true"] assert] // Test tostring
[[[#true if: '"foo" else: '"bar"] equals: "foo"] assert] // Test if
[[[[1 equals: 2] if: '"foo" else: '"bar"] equals: "bar"] assert] // Test if
// Test #Integer
[[[#Integer new] equals: 0] assert] // Test new
[[[#Integer new: 13] equals: 13] assert] // Test new
[[[#Integer new: 12.34] equals: 12] assert] // Test new
[[[#Integer new: "13"] equals: 13] assert] // Test new
[[[#Integer new: "0x13"] equals: 19] assert] // Test new
[[[123 tostring] equals: "123"] assert] // Test tostring
[[[123 tostring: 16] equals: "7B"] assert] // Test tostring:
[[[123 hash] equals: [123 hash]] assert] // Test hash
[[123 equals: 123] assert] // Test equals
[[[13 add: 42] equals: 55] assert] // Test add
[[[13 sub: 42] equals: -29] assert] // Test sub
[[[3 mult: 4] equals: 12] assert] // Test mult
[[[144 div: 12] equals: 12] assert] // Test div
[[[147 mod: 12] equals: 3] assert] // Test mod
[[[[[[[10 range] cdr] cdr] cdr] car] equals: 3] assert] // Test range
[[[123 minus] equals: -123] assert] // Test minus
// Test #Float
[[[#Float new] equals: 0.0] assert] // Test new
[[[#Float new: 12] equals: 12.0] assert] // Test new
[[[#Float new: 12.34] equals: 12.34] assert] // Test new
[[[#Float new: "12.34"] equals: 12.34] assert] // Test new
[[[12.34 tostring] equals: "12.34"] assert] // Test tostring
[[[12.34 hash] equals: [12.34 hash]] assert] // Test hash
[[12.34 equals: 12.34] assert] // Test equals
[[[12.0 add: 0.34] equals: 12.34] assert] // Test add
[[[12.34 sub: 0.34] equals: 12.0] assert] // Test sub
[[[1.5 mult: 4.0] equals: 6.0] assert] // Test mult
[[[6.0 div: 4.0] equals: 1.5] assert] // Test div
[[[12.34 minus] equals: -12.34] assert] // Test minus
// Test #String
'sam // Test quoting
"The rain in Spain" // Test quoting
"A\nB\nC" // Test quoting
[[[["foo" hash] instance-of] equals: #Integer] assert] // Test hash
[["foo" equals: 'foo] assert] // Test equals
[[["foo" append: "bar"] equals: "foobar"] assert] // Test append
[#Environment at: "foo" put: 42]
[[foo equals: 42] assert] // Test eval
// Test #List
(1 2) // Test parsing, cons, printing
'(1, 2) // Test parsing, cons, printing
[[['(1 2) car] equals: 1] assert] // Test car
[[['(1, 2) cdr] equals: 2] assert] // Test cdr
[[[([1 add: 1] [2 add: 3]) car] equals: 2] assert] // Test eval
[[[[((1 2)) map: {(u v) [u add: v]}] car] equals: 3] assert] // Test map
[[[[(12) foreach: {(u) [u add: u]}] car] equals: 24] assert] // Test foreach
// Test #Method_Call
// Used lots before...
[[['[1 add: 2] eval] equals: 3] assert] // Test eval
'[1 add: 2] // Test tostring
// Test #Block
[[[{(x) [x mult: x]} eval: (3)] equals: 9] assert] // Test eval
{(x) [x mult: x]} // Test tostring
// Test #Dictionary
[#Environment at: 'd put: [#Dictionary new]] // Test new
[d at: "foo" put: 123] // Test at:put:
[[[[d at: "foo"] cdr] equals: 123] assert] // Test at
[[[[d keys] car] equals: "foo"] assert] // Test keys
[[[d tostring] equals: "((foo, 123))"] assert]
[d delete: "foo"] // Test delete
[[[d at: "foo"] equals: #nil] assert] // Test delete
// Test #Environment
[#Environment at: 'foo put: 77]
[[foo equals: 77] assert] // Test at:put:
[foo = [66 add: 33]] // Test assign shorthand
[[foo equals: 99] assert]
[#Environment push]
[[foo equals: 99] assert] // Test access to older env
[#Environment at: 'foo put: 66]
[[foo equals: 66] assert] // Test access to older env
[#Environment new: 'foo put: 101]
[[foo equals: 101] assert] // Test new env
[#Environment pop]
[[foo equals: 66] assert] // Test revert to older env
// Test #File
[#File new: "test.inp" mode: "r+"] // Test new
// Test #Module
// [#Module new: "./socket.so"] // Test new
// #Socket // Test loading
// [s = [#Socket new]] // Test loading
// Test mem mgmt
[#System collect]