Last active
January 4, 2016 05:19
-
-
Save andrewcsmith/8573993 to your computer and use it in GitHub Desktop.
UnitTest class and usage that I'm working on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UnitTest { | |
var <assertionCount = 0, <successCount = 0, <failureCount = 0; | |
test { | |
arg name, func; | |
("Testing: " ++ name).postln; | |
func.value(this); | |
("Assertions: " ++ assertionCount ++ "\t Successes: " ++ successCount ++ "\t Failures: " ++ failureCount).postln; | |
} | |
assert { | |
arg truthValue; | |
assertionCount = assertionCount+1; | |
truthValue = truthValue.value; | |
if(truthValue, | |
{ successCount = successCount+1 }, | |
{ failureCount = failureCount+1 } | |
); | |
^truthValue; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
u = UnitTest.new; | |
u.test("that true is true", { | |
arg self; | |
self.assert({true}); | |
self.assert({1 > 0}); | |
self.assert({false}); | |
}); | |
) | |
/* Prints the following: | |
Testing: that true is true | |
Assertions: 3 Successes: 2 Failures: 1 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment