Last active
August 29, 2015 13:57
-
-
Save boughtonp/9371238 to your computer and use it in GitHub Desktop.
Workaround for incorrect assertSame / assertNotSame functionality in Testbox - for official fix see https://ortussolutions.atlassian.net/browse/TESTBOX-76
This file contains hidden or 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
component | |
{ | |
function init() | |
{ | |
Variables.System = createObject("java","java.lang.System"); | |
} | |
this.isSameInstance = function ( any Expected , any Actual , string Message ) | |
{ | |
Arguments.Expected = System.identityHashCode(Arguments.Expected); | |
Arguments.Actual = System.identityHashCode(Arguments.Actual); | |
if ( Arguments.Expected EQ Arguments.Actual ) | |
return; | |
if ( NOT StructKeyExists(Arguments,'Message') ) | |
Arguments.Message = "Expected two objects to be same instance but received different HashCode values [#Arguments.Expected#,#Arguments.Actual#]."; | |
throw(type="TestBox.AssertionFailed",message=Arguments.Message); | |
}; | |
this.isNotSameInstance = function ( any Expected , any Actual , string Message ) | |
{ | |
Arguments.Expected = Variables.System.identityHashCode(Arguments.Expected); | |
Arguments.Actual = Variables.System.identityHashCode(Arguments.Actual); | |
if ( Arguments.Expected NEQ Arguments.Actual ) | |
return; | |
if ( NOT StructKeyExists(Arguments,'Message') ) | |
Arguments.Message = "Expected two objects to be different instances but received same HashCode value [#Arguments.Expected#]."; | |
throw(type="TestBox.AssertionFailed",message=Arguments.Message); | |
}; | |
} |
This file contains hidden or 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
addAssertions( new path.to.below.Component() ); | |
$assert.isSameInstance( ObjA , ObjB ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment