Bootstrap code cleanups.
[cslatevm.git] / tests / test.slate
blobbe104e8ba1fe440f50d267aabb3042b6d54f2686
1 testing UnitTests addPrototype: #SUnit derivedFrom: {TestCase}.
2 "This is both an example of writing tests and a self test for the SUnit.
3 The tests here are pretty strange, since you want to make sure things don't blow up.
4 You should not generally have to write tests this complicated in structure,
5 although they will be far more complicated in terms of your own objects-
6 more assertions, more complicated setup."
7 UnitTests SUnit addSlot: #hasRun valued: False.
8 UnitTests SUnit addSlot: #hasSetup valued: False.
9 UnitTests SUnit addSlot: #hasRanOnce valued: False.
11 t@(UnitTests SUnit traits) setUp
13   t hasSetup: True.
16 t@(UnitTests SUnit traits) error
17 [3 zork].
19 t@(UnitTests SUnit traits) noop
20 [].
22 t@(UnitTests SUnit traits) fail
23 [t assert: False].
25 t@(UnitTests SUnit traits) setRun
27   t hasRun: True.
30 t@(UnitTests SUnit traits) assertForTestResult: result runs: ran passed: passed
31   failed: failed errors: broke
33   t assert: result runCount = ran.
34   t assert: result passedCount = passed.
35   t assert: result failureCount = failed.
36   t assert: result errorCount = broke.
39 t@(UnitTests SUnit traits) testAssert
41   t assert: True.
42   t deny: False.
45 t@(UnitTests SUnit traits) testDebugger
46 "Disabled, so that running all tests passes. Uncomment to enable.
47 This test should break."
48 ["3 zork"].
50 t@(UnitTests SUnit traits) testDefects
51 [| result suite error failure |
52   suite: TestSuite new.
53   suite tests include: (error: (t newForSelector: #error)).
54   suite tests include: (failure: (t newForSelector: #fail)).
55   error logErrors: False.
56   failure logErrors: False.
57   result: suite run.
58   t assert: result defects = {error. failure}.
59   t assertForTestResult: result
60     runs: 2 passed: 0 failed: 1 errors: 1.
63 t@(UnitTests SUnit traits) testException
65   t should: [t signalFailureDescription: 'Foo'] raise: TestFailure.
66   t should: [TestResult signalFailureDescription: 'Foo'] raise: Error.
67   t shouldnt: [TestResult signalFailureDescription: 'Foo'] raise: TestFailure.
70 t@(UnitTests SUnit traits) testError
71 [| case result |
72   case: (t newForSelector: #error).
73   case logErrors: False.
74   result: case run.
75   t assertForTestResult: result
76     runs: 1 passed: 0 failed: 0 errors: 1.
79 t@(UnitTests SUnit traits) testFail
80 [| case result |
81   case: (t newForSelector: #fail).
82   case logErrors: False.
83   result: case run.
84   t assertForTestResult: result
85     runs: 1 passed: 0 failed: 1 errors: 0.
88 t@(UnitTests SUnit traits) testFailDebugger
89 "Disabled, so running all tests passes. Uncomment to enable.
90 This test should fail."
91 ["t fail"].
93 t@(UnitTests SUnit traits) testIsNotRerunOnDebug
94 [| case |
95   case: (t newForSelector: #testRanOnlyOnce).
96   case run.
97   "case invokeDebugger."
100 t@(UnitTests SUnit traits) testShould
102   t should: [True].
103   t shouldnt: [False].
106 t@(UnitTests SUnit traits) testRan
107 [| case |
108   case: (t newForSelector: #setRun).
109   case run.
110   t assert: case hasSetup.
111   t assert: case hasRun.
114 t@(UnitTests SUnit traits) testRanOnlyOnce
116   t assert: t hasRanOnce ~= True.
117   t hasRanOnce: True.
120 t@(UnitTests SUnit traits) testResult
121 [| case result |
122   case: (t newForSelector: #noop).
123   result: case run.
124   t assertForTestResult: result
125     runs: 1 passed: 1 failed: 0 errors: 0.
126   "Ensure prototype isn't modified"
127   t assertForTestResult: TestResult
128     runs: 0 passed: 0 failed: 0 errors: 0.
131 t@(UnitTests SUnit traits) suite
132 [t suiteForSelectors: {
133   #testResult.
134   #testRanOnlyOnce.
135   #testShould.
136   #testIsNotRerunOnDebug.
137   #testFailDebugger.
138   #testFail.
139   #testError.
140   #testAssert.
141   #testDebugger.
142   #testDefects.
143   #testException.