|
From: Darren C. <da...@dc...> - 2006-03-22 05:29:16
|
I have this simple test [1] and when it fails I want to see why, but all
I get is success=false [2].
How about an assertEqualsVerbose function that when it has a failure it
appends result and expected to the msg. So replace the code in [3] with [4].
Or even better than adding a new function add a public static var
verboseAsserts:Boolean to the Assert class.
The alternative seems to be firing up a debugger or adding trace
statements to my unit test code.
Any opinions?
Darren
[1]:
var x:Something=new Something;
var result:Array=x.split_by_comma("ex,why,zed");
var expected:Array=["ex","why","zed"];
assertEquals("csv split of 'ex,why,zed'",result,expected);
[2]:
success : false
output : F
assertion : assertEquals
message : csv split of 1,2
methodName : testSplits
className : SomethingTests
[3]:
addTestResult(String(msg), "assertEquals", assertion1 === assertion2);
[4]:
if(assertion1 === assertion2)
addTestResult(String(msg),"assertEquals",true);
else
addTestResult(
String(msg)+":"+assertion1+":"+assertion2,
"assertEquals",false);
|
|
From: Robert P. <in...@ro...> - 2006-03-22 05:58:31
|
AsUnit 3 formats the message to include the actual and expected. It should
be ported to AsUnit 2.5.
Robert
-----Original Message-----
From: asu...@li...
[mailto:asu...@li...]On Behalf Of Darren
Cook
Sent: March 21, 2006 9:29 PM
To: asunit-users
Subject: [Asunit-users] Verbose assertEquals
I have this simple test [1] and when it fails I want to see why, but all
I get is success=false [2].
How about an assertEqualsVerbose function that when it has a failure it
appends result and expected to the msg. So replace the code in [3] with [4].
Or even better than adding a new function add a public static var
verboseAsserts:Boolean to the Assert class.
The alternative seems to be firing up a debugger or adding trace
statements to my unit test code.
Any opinions?
Darren
[1]:
var x:Something=new Something;
var result:Array=x.split_by_comma("ex,why,zed");
var expected:Array=["ex","why","zed"];
assertEquals("csv split of 'ex,why,zed'",result,expected);
[2]:
success : false
output : F
assertion : assertEquals
message : csv split of 1,2
methodName : testSplits
className : SomethingTests
[3]:
addTestResult(String(msg), "assertEquals", assertion1 === assertion2);
[4]:
if(assertion1 === assertion2)
addTestResult(String(msg),"assertEquals",true);
else
addTestResult(
String(msg)+":"+assertion1+":"+assertion2,
"assertEquals",false);
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Asunit-users mailing list
Asu...@li...
https://lists.sourceforge.net/lists/listinfo/asunit-users
|
|
From: Darren C. <da...@dc...> - 2006-03-22 08:08:36
|
> AsUnit 3 formats the message to include the actual and expected. It should > be ported to AsUnit 2.5. Thanks for the tip. I just skimmed the as3 code and the format() function (and the three failXXX() functions) should be easy to backport to as2. I'll volunteer to do that tomorrow unless somebody gives a reason not to. Darren |
|
From: Darren C. <da...@dc...> - 2006-03-25 03:16:50
|
> How about an assertEqualsVerbose function that when it has a failure it
> appends result and expected to the msg. ...
I've done this, using the latest svn. Can I have svn write access (my SF
username is darrencook)? Or let me know who I should send files to.
I'm still having a problem using assertEquals with arrays. See the
function [1] below. The first assert fails with:
csv split of 'ex,why,zed' expected:<ex,why,zed> but was:<ex,why,zed>
The other, more specific, tests all pass.
assertEquals uses ===. What kind of difference it is seeing?!
Darren
[1]
public function testSplits(){
var result:Array=String("ex,why,zed").split(",");
var expected:Array=["ex","why","zed"];
assertEquals("csv split of 'ex,why,zed'",result,expected);
assertEquals("csv split of 'ex,why,zed':types",typeof result,typeof
expected);
assertEquals("csv split of
'ex,why,zed':lengths",result.length,expected.length);
assertEquals("csv split of 'ex,why,zed':[0]",result[0],expected[0]);
assertEquals("csv split of 'ex,why,zed':[1]",result[1],expected[1]);
assertEquals("csv split of 'ex,why,zed':[2]",result[2],expected[2]);
}
|
|
From: Robert P. <in...@ro...> - 2006-03-25 19:10:39
|
> assertEquals uses ===. What kind of difference it is seeing?!
You have two different arrays; they aren't the same object, so == or ===
will be false. AsUnit lets you define an equals() method to compare equality
of objects.
Robert
-----Original Message-----
From: asu...@li...
[mailto:asu...@li...]On Behalf Of Darren
Cook
Sent: March 24, 2006 7:16 PM
To: asu...@li...
Subject: Re: [Asunit-users] Verbose assertEquals
> How about an assertEqualsVerbose function that when it has a failure it
> appends result and expected to the msg. ...
I've done this, using the latest svn. Can I have svn write access (my SF
username is darrencook)? Or let me know who I should send files to.
I'm still having a problem using assertEquals with arrays. See the
function [1] below. The first assert fails with:
csv split of 'ex,why,zed' expected:<ex,why,zed> but was:<ex,why,zed>
The other, more specific, tests all pass.
assertEquals uses ===. What kind of difference it is seeing?!
Darren
[1]
public function testSplits(){
var result:Array=String("ex,why,zed").split(",");
var expected:Array=["ex","why","zed"];
assertEquals("csv split of 'ex,why,zed'",result,expected);
assertEquals("csv split of 'ex,why,zed':types",typeof result,typeof
expected);
assertEquals("csv split of
'ex,why,zed':lengths",result.length,expected.length);
assertEquals("csv split of 'ex,why,zed':[0]",result[0],expected[0]);
assertEquals("csv split of 'ex,why,zed':[1]",result[1],expected[1]);
assertEquals("csv split of 'ex,why,zed':[2]",result[2],expected[2]);
}
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Asunit-users mailing list
Asu...@li...
https://lists.sourceforge.net/lists/listinfo/asunit-users
|
|
From: Peter H. <pet...@gm...> - 2006-03-25 19:23:32
|
assertEquals should probably be extended to handle a few extra types (for
ex, Array and XML). assertSame tests if the two arguments are the same
object, while assertEquals is more concerned with the value.
Peter
On 3/25/06, Robert Penner <in...@ro...> wrote:
>
> > assertEquals uses =3D=3D=3D. What kind of difference it is seeing?!
>
> You have two different arrays; they aren't the same object, so =3D=3D or =
=3D=3D=3D
> will be false. AsUnit lets you define an equals() method to compare
> equality
> of objects.
>
> Robert
>
>
> -----Original Message-----
> From: asu...@li...
> [mailto:asu...@li...]On Behalf Of Darren
> Cook
> Sent: March 24, 2006 7:16 PM
> To: asu...@li...
> Subject: Re: [Asunit-users] Verbose assertEquals
>
>
>
> > How about an assertEqualsVerbose function that when it has a failure it
> > appends result and expected to the msg. ...
>
> I've done this, using the latest svn. Can I have svn write access (my SF
> username is darrencook)? Or let me know who I should send files to.
>
> I'm still having a problem using assertEquals with arrays. See the
> function [1] below. The first assert fails with:
> csv split of 'ex,why,zed' expected:<ex,why,zed> but was:<ex,why,zed>
>
> The other, more specific, tests all pass.
>
> assertEquals uses =3D=3D=3D. What kind of difference it is seeing?!
>
> Darren
>
>
> [1]
> public function testSplits(){
> var result:Array=3DString("ex,why,zed").split(",");
> var expected:Array=3D["ex","why","zed"];
> assertEquals("csv split of 'ex,why,zed'",result,expected);
> assertEquals("csv split of 'ex,why,zed':types",typeof result,typeof
> expected);
> assertEquals("csv split of
> 'ex,why,zed':lengths",result.length,expected.length);
> assertEquals("csv split of 'ex,why,zed':[0]",result[0],expected[0]);
> assertEquals("csv split of 'ex,why,zed':[1]",result[1],expected[1]);
> assertEquals("csv split of 'ex,why,zed':[2]",result[2],expected[2]);
> }
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> _______________________________________________
> Asunit-users mailing list
> Asu...@li...
> https://lists.sourceforge.net/lists/listinfo/asunit-users
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> _______________________________________________
> Asunit-users mailing list
> Asu...@li...
> https://lists.sourceforge.net/lists/listinfo/asunit-users
>
|
|
From: Darren C. <da...@dc...> - 2006-03-27 09:59:41
|
> assertEquals should probably be extended to handle a few extra types (for > ex, Array and XML). assertSame tests if the two arguments are the same > object, while assertEquals is more concerned with the value. I agree. Instead of special code for XML, why not special code for all objects that do not have an equals function defined? >>>assertEquals uses ===. What kind of difference it is seeing?! >> >>You have two different arrays; they aren't the same object, Thanks. I was confusing javascript and php. Darren |
|
From: Darren C. <da...@dc...> - 2006-03-29 08:40:07
|
>>assertEquals should probably be extended to handle a few extra types (for >>ex, Array and XML). assertSame tests if the two arguments are the same >>object, while assertEquals is more concerned with the value. > > I agree. Instead of special code for XML, why not special code for all > objects that do not have an equals function defined? I've gone ahead and done this, for all types of objects. See the Assert.as file in the zip file attached to the other email I just sent. Warning: it is backwards-incompatible if you've used assertEquals to compare objects/arrays when you really intended to do what assertSame does. Apologies if "fix your code" sounds too harsh :-). Darren |
|
From: Luke B. <lb...@gm...> - 2006-04-08 22:02:52
|
Thanks so much for putting in this work Darren. I do agree that the proposed change is an improvement over what we have today and I am happy to integrate the patch for my own projects. I am, however, concerned about breaking other people's existing tests. Personally, to your point, I don't think this would break any of my tests and if it did, it would be trivial to fix. Unfortunately, I'm hesitant to release this as it may have a negative effect on other people's time. In light of these concerns, I'd like to put it to a vote for our users. If you're interested in this topic, please respond to the list with your vote: a) You would like to see assertSame and assertEquals cleaned up according t= o the previous discussion b) You would like to see assertSame and assertEquals left as is I vote for (a), but would defer to the community if they feel strongly abou= t it. Since Darren did the work already, I'm going to assume that he's in the a) camp too. Votes: a) 2 b) 0 Anyone want to weigh in on this? Thanks, Luke Bayes www.asunit.org I've gone ahead and done this, for all types of objects. See the > Assert.as file in the zip file attached to the other email I just sent. > > Warning: it is backwards-incompatible if you've used assertEquals to > compare objects/arrays when you really intended to do what assertSame > does. Apologies if "fix your code" sounds too harsh :-). > > Darren > |
|
From: erixtekila <eri...@gm...> - 2006-04-09 08:46:10
|
>> Assert.as file in the zip file attached to the other email I just >> sent. >> >> Warning: it is backwards-incompatible if you've used assertEquals to >> compare objects/arrays when you really intended to do what assertSame >> does. Apologies if "fix your code" sounds too harsh :-). >> >> Darren Could it be possible to tell what is this change about and where it's possible to follow the changes. diff available ? between what svn release ? In order to choose, we should be able to better follow the discussion. > In light of these concerns, I'd like to put it to a vote for our users. > > If you're interested in this topic, please respond to the list with > your vote: > > a) You would like to see assertSame and assertEquals cleaned up > according to the previous discussion > b) You would like to see assertSame and assertEquals left as is > > I vote for (a), but would defer to the community if they feel strongly > about it. > Since Darren did the work already, I'm going to assume that he's in > the a) camp too. > Best regards. ----------- erixtekila http://blog.v-i-a.net/ |
|
From: Darren C. <da...@dc...> - 2006-04-09 23:28:59
|
>>> Warning: it is backwards-incompatible if you've used assertEquals to
>>> compare objects/arrays when you really intended to do what assertSame
>>> does. Apologies if "fix your code" sounds too harsh :-).
>
> Could it be possible to tell what is this change about and where it's
> possible to follow the changes.
> diff available ? between what svn release ?
Here is a simple motivating example of the current problem with
assertEquals:
var result:Array=String("ex,why,zed").split(",");
var expected:Array=["ex","why","zed"];
assertEquals("csv split of 'ex,why,zed'",result,expected);
It is natural to expect this test to pass, but it fails because
assertEquals uses === for arrays, which is an identity test in
actionscript/javascript.
assertSame() is for identity tests, whereas assertEquals() is for
same-value tests. Therefore I feel it can be classed as a bug; Luke's
concern is that it breaks backwards compatibility for anyone who used
assertEquals to compare two arrays or objects when the behaviour of
assertSame was what they intended.
The patch is not in SVN, but is available in my socket-server patch [1].
The related changes are in Assert.as's assertEquals(), and a new static
function compareObjects() to compare arrays and objects.
Darren
[1]:
http://dcook.org/software/asunit_socket_server.zip (21K)
|
|
From: erixtekila <eri...@gm...> - 2006-04-10 09:04:54
|
> var result:Array=String("ex,why,zed").split(",");
> var expected:Array=["ex","why","zed"];
> assertEquals("csv split of 'ex,why,zed'",result,expected);
>
> It is natural to expect this test to pass, but it fails because
> assertEquals uses === for arrays, which is an identity test in
> actionscript/javascript.
>
> assertSame() is for identity tests, whereas assertEquals() is for
> same-value tests.
Ah, yes.
I was feeling that this problem has already been fixed.
Let me remember, in the time of the as2 only trunk, the solution was to
give AssertSame a way to compare two complex objects.
So the idea was to use an IComparator interface that declare an "equal"
method.
Something along the line of Java.
If one wants to use AssertSame on two complex objects, he can use that
equal method to build comparison logic.
BTW, I feel that this solution was not adopted by asunit team,
eventhough I find it really elegant.
I did it, for my side.
So, in order to vote, I vote on #a.
Backward compatibility is not mandatory when functionnality is not
working.
Cheers
-----------
erixtekila
http://blog.v-i-a.net/
|
|
From: Darren C. <da...@dc...> - 2006-04-10 09:18:13
|
> If one wants to use AssertSame on two complex objects, he can use that > equal method to build comparison logic. That code is still there (and if an object has an equals method that takes precedence). My patch just saves you have to make the equals method when you simply want to compare all fields. Darren |
|
From: erixtekila <eri...@gm...> - 2006-04-10 10:57:37
|
Le 10 avr. 06, =E0 11:17, Darren Cook a =E9crit : >> If one wants to use AssertSame on two complex objects, he can use = that >> equal method to build comparison logic. > > That code is still there (and if an object has an equals method that > takes precedence). > > My patch just saves you have to make the equals method when you simply > want to compare all fields. OK, great. That means that it could compare native objects like Arrays and=20 Objects, am I right ? So I vote a) PS : I'll give a shot to your php server soon. Very interesting stuff. ----------- erixtekila http://blog.v-i-a.net/= |
|
From: Robert P. <in...@ro...> - 2006-04-11 22:45:22
|
<<<
Let me remember, in the time of the as2 only trunk, the solution was to
give AssertSame a way to compare two complex objects.
So the idea was to use an IComparator interface that declare an "equal"
method.
>>>
This was for assertEquals(), not assertSame().
Robert
-----Original Message-----
From: asu...@li...
[mailto:asu...@li...]On Behalf Of erixtekila
Sent: April 10, 2006 1:58 AM
To: asu...@li...
Subject: Re: [Asunit-users] Verbose assertEquals
> var result:Array=String("ex,why,zed").split(",");
> var expected:Array=["ex","why","zed"];
> assertEquals("csv split of 'ex,why,zed'",result,expected);
>
> It is natural to expect this test to pass, but it fails because
> assertEquals uses === for arrays, which is an identity test in
> actionscript/javascript.
>
> assertSame() is for identity tests, whereas assertEquals() is for
> same-value tests.
Ah, yes.
I was feeling that this problem has already been fixed.
Let me remember, in the time of the as2 only trunk, the solution was to
give AssertSame a way to compare two complex objects.
So the idea was to use an IComparator interface that declare an "equal"
method.
Something along the line of Java.
If one wants to use AssertSame on two complex objects, he can use that
equal method to build comparison logic.
BTW, I feel that this solution was not adopted by asunit team,
eventhough I find it really elegant.
I did it, for my side.
So, in order to vote, I vote on #a.
Backward compatibility is not mandatory when functionnality is not
working.
Cheers
-----------
erixtekila
http://blog.v-i-a.net/
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Asunit-users mailing list
Asu...@li...
https://lists.sourceforge.net/lists/listinfo/asunit-users
|
|
From: erixtekila <eri...@gm...> - 2006-04-11 23:04:10
|
> <<< > Let me remember, in the time of the as2 only trunk, the solution was to > give AssertSame a way to compare two complex objects. > So the idea was to use an IComparator interface that declare an "equal" > method. >>>> > > This was for assertEquals(), not assertSame(). For sure, thanks for clarification. I reread a Junit docs (http://www.oreilly.com/catalog/jextprockbk/chapter/ch04.pdf) <excerpt> Equality comparison The assertSame( ) method compares two object references, ensuring that they both refer to the same memory address. assertSame( ) uses the == operator for its comparison. The following two tests are functionally identical: assertSame("Expected the two parts to be identical.", part1, part2); assertTrue("Expected the two parts to be identical.", part1 == part2); While assertSame( ) compares memory addresses, assertEquals( ) compares contents. For objects, this means the .equals( ) method is used instead of ==. assertEquals( ) has numerous overloaded implementations that compare objects to other objects, or primitives to other primitives. </excerpt> Best. ----------- erixtekila http://blog.v-i-a.net/ |
|
From: Luke B. <lb...@gm...> - 2006-04-12 20:58:31
|
I'm not looking at the source right now, but I believe that in our case, we'll want to use the =3D=3D=3D operator for assertSame... Right? Luke |
|
From: R.A. W. <em...@ry...> - 2006-04-13 05:22:19
|
The difference between == and === can be hard to infer with ActionScript. The following test output might be helpful to some who are still wondering what's up with equals-equals and equals-equals-equals: Assert Same (same value, same identity): true: (1 === 1) for Number true: (true === true) for Boolean true: (1 === 1) for String true: (foo,bar === foo,bar) for Array true: ([object Object] === [object Object]) for Object ---------- Assert Same (same value, different identity): true: (1 === 1) for Number true: (true === true) for Boolean true: (1 === 1) for String false: (foo,bar === foo,bar) for Array false: ([object Object] === [object Object]) for Object ---------- Assert Same (same value, different type): false: (1 === 1) for Number vs String false: (true === 1) for Boolean vs Number false: (1 === true) for String vs Boolean false: (0 === 0) for Number vs String false: (false === 0) for Boolean vs Number false: (0 === false) for String vs Boolean ---------- Assert Equals (same value, same identity): true: (1 == 1) for Number true: (true == true) for Boolean true: (1 == 1) for String true: (foo,bar == foo,bar) for Array true: ([object Object] == [object Object]) for Object ---------- Assert Equals (same value, different identity): true: (1 == 1) for Number true: (true == true) for Boolean true: (1 == 1) for String false: (foo,bar == foo,bar) for Array false: ([object Object] === [object Object]) for Object ---------- Assert Equals (same value, different type): true: (1 == 1) for Number vs String true: (true == 1) for Boolean vs Number true: (1 == true) for String vs Boolean true: (0 == 0) for Number vs String true: (false == 0) for Boolean vs Number true: (0 == false) for String vs Boolean ---------- Assert Same (different identity, same value, stringified): true: (foo,bar === foo,bar) for Array.toString() true: ([object Object] === [object Object]) for Object.toString() ---------- Assert Equals (different identity, same value, stringified): true: (foo,bar == foo,bar) for Array.toString() true: ([object Object] == [object Object]) for Object.toString() -rw Luke Bayes wrote: > I'm not looking at the source right now, but I believe that in our case, > we'll want to use the === operator for assertSame... > > Right? > > > Luke |