-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.r
More file actions
28 lines (22 loc) · 960 Bytes
/
tests.r
File metadata and controls
28 lines (22 loc) · 960 Bytes
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
Rebol [
Title: "Tiny Framework - test driver"
]
testFilenameSuffix: copy "Test.r"
testFunctionNamePrefix: copy "test"
; test files are those that end with "Test.r"
testFiles: findFiles/matching %tests/ lambda [endsWith ? testFilenameSuffix]
; runs all functions that start with test in testFiles
; runs setUp and tearDown functions before each test function, if they exist
foreach testFile testFiles [
testFileContents: context load testFile
testFileObject: testFileContents/tests
wordsInTestFile: copy words-of testFileObject
testFunctions: f_filter lambda [startsWith to-string ? testFunctionNamePrefix] wordsInTestFile
; actually call each test function; we don't care about the results
foreach testFunction testFunctions [
if in testFileObject 'setUp [testFileObject/setUp]
testFileObject/:testFunction
if in testFileObject 'tearDown [testFileObject/tearDown]
]
]
print "all tests pass"