Fixed allSelectorsSent because a simpler implementation was overriding the original.
[cslatevm.git] / tests / test.slate
blob6b29b6ceb2ed79ff4697510df33c9cd41647c1f9
1 testing UnitTests define: #SUnit &parents: {TestCase} &slots: {
2   #hasRun -> False.
3   #hasSetup -> False.
4   #hasRanOnce -> False.
5 }.
6 "This is both an example of writing tests and a self test for the SUnit.
7 The tests here are pretty strange, since you want to make sure things don't blow up.
8 You should not generally have to write tests this complicated in structure,
9 although they will be far more complicated in terms of your own objects-
10 more assertions, more complicated setup."
12 t@(UnitTests SUnit traits) setUp
14   t hasSetup: True.
17 t@(UnitTests SUnit traits) error
18 [3 zork].
20 t@(UnitTests SUnit traits) noop
21 [].
23 t@(UnitTests SUnit traits) fail
24 [t assert: False].
26 t@(UnitTests SUnit traits) setRun
28   t hasRun: True.
31 t@(UnitTests SUnit traits) assertForTestResult: result runs: ran passed: passed
32   failed: failed errors: broke
34   t assert: result runCount = ran.
35   t assert: result passedCount = passed.
36   t assert: result failureCount = failed.
37   t assert: result errorCount = broke.
40 t@(UnitTests SUnit traits) testAssert
42   t assert: True.
43   t deny: False.
46 t@(UnitTests SUnit traits) testDebugger
47 "Disabled, so that running all tests passes. Uncomment to enable.
48 This test should break."
49 ["3 zork"].
51 t@(UnitTests SUnit traits) testDefects
53   suite ::= TestSuite new.
54   suite tests include: (error ::= t newForSelector: #error).
55   suite tests include: (failure ::= t newForSelector: #fail).
56   error logErrors := False.
57   failure logErrors := False.
58   result ::= suite run.
59   t assert: result defects = {error. failure}.
60   t assertForTestResult: result
61     runs: 2 passed: 0 failed: 1 errors: 1.
64 t@(UnitTests SUnit traits) testException
66   t should: [t signalFailureDescription: 'Foo'] raise: TestFailure.
67   t should: [TestResult signalFailureDescription: 'Foo'] raise: Error.
68   t shouldnt: [TestResult signalFailureDescription: 'Foo'] raise: TestFailure.
71 t@(UnitTests SUnit traits) testError
73   case ::= t newForSelector: #error.
74   case logErrors := False.
75   result ::= case run.
76   t assertForTestResult: result
77     runs: 1 passed: 0 failed: 0 errors: 1.
80 t@(UnitTests SUnit traits) testFail
82   case ::= t newForSelector: #fail.
83   case logErrors := False.
84   result ::= case run.
85   t assertForTestResult: result
86     runs: 1 passed: 0 failed: 1 errors: 0.
89 t@(UnitTests SUnit traits) testFailDebugger
90 "Disabled, so running all tests passes. Uncomment to enable.
91 This test should fail."
92 ["t fail"].
94 t@(UnitTests SUnit traits) testIsNotRerunOnDebug
96   case ::= t newForSelector: #testRanOnlyOnce.
97   case run.
98   "case invokeDebugger."
101 t@(UnitTests SUnit traits) testShould
103   t should: [True].
104   t shouldnt: [False].
107 t@(UnitTests SUnit traits) testRan
109   case ::= t newForSelector: #setRun.
110   case run.
111   t assert: case hasSetup.
112   t assert: case hasRun.
115 t@(UnitTests SUnit traits) testRanOnlyOnce
117   t assert: t hasRanOnce ~= True.
118   t hasRanOnce: True.
121 t@(UnitTests SUnit traits) testResult
123   case ::= t newForSelector: #noop.
124   result ::= case run.
125   t assertForTestResult: result
126     runs: 1 passed: 1 failed: 0 errors: 0.
127   "Ensure prototype isn't modified"
128   t assertForTestResult: TestResult
129     runs: 0 passed: 0 failed: 0 errors: 0.
132 t@(UnitTests SUnit traits) suite
133 [t suiteForSelectors: {
134   #testResult.
135   #testRanOnlyOnce.
136   #testShould.
137   #testIsNotRerunOnDebug.
138   #testFailDebugger.
139   #testFail.
140   #testError.
141   #testAssert.
142   #testDebugger.
143   #testDefects.
144   #testException.