Created
November 4, 2010 18:40
-
-
Save anttih/662925 to your computer and use it in GitHub Desktop.
Tests for Object assert
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
Protos AssertionException := Exception clone | |
Object do( | |
assert := method(v, m, | |
if(true != v, | |
m ifNil(m = "true != (#{ call argAt(0) })" interpolate) | |
AssertionException raise(m) | |
) | |
) | |
) |
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
doFile("Assert.io") | |
doFile("UnitTest.io") // my patched UnitTest.io | |
AssertTest := UnitTest clone do( | |
/* | |
Object does not respond to debug* messages on my installation | |
test_does_not_throw_when_debugging_off := method( | |
debugOff | |
assert(false) | |
debugOn | |
) | |
*/ | |
test_no_params_throws := method( | |
e := try(assert()) | |
e catch(AssertionException, | |
assertEquals(e error, "true != (nil)") | |
) pass | |
) | |
test_does_not_throw_when_true := method( | |
assert(true) | |
) | |
test_throws_assertionException_when_false := method( | |
e := try(assert(false)) | |
e catch(AssertionException) pass | |
) | |
test_message_is_call_message_when_no_message := method( | |
e := try(assert(false == true)) | |
e catch(AssertionException, | |
assertEquals(e error, "true != (false ==(true))") | |
) pass | |
) | |
test_uses_passed_in_message := method( | |
e := try(assert(false, "Message")) | |
e catch(AssertionException, | |
assertEquals(e error, "Message") | |
) pass | |
) | |
test_more_complicated_call_message := method( | |
e := try(assert((50 + 50) / 100 != 1)) | |
e catch(AssertionException, | |
assertEquals(e error, "true != ((50 +(50)) /(100) !=(1))") | |
) pass | |
) | |
//test_this_should_fail := method( | |
// #fail("Failure!") | |
//) | |
) | |
FileCollector run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment