Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you add an error message for constructor differences? #279

Closed
LarryBattle opened this issue Jul 9, 2012 · 2 comments
Closed

Could you add an error message for constructor differences? #279

LarryBattle opened this issue Jul 9, 2012 · 2 comments

Comments

@LarryBattle
Copy link

Could you add an error message for constructor differences?

Example:

test("test constructors", function(){
    var obj = {a:1};
    var Obj = function(){
        this.a = 1;
    };
    var Foo = function(){
        this.a = 1;
    };

    deepEqual( new Obj(), obj );
    deepEqual( obj, new Obj() );
    deepEqual( new Foo(), new Obj() );
    deepEqual( new Obj(), new Foo() );
});

All the tests fail with the same error message.
failed
Expected:

{
  "a": 1
}

Live Demo:
http://jsfiddle.net/bVpfU/1/

It would be nice if they failed like this.

"Constructors or prototypes are different."

{
  "a": 1
}
@jzaefferer
Copy link
Member

Seems reasonable. As Scott said, "It's just jsDump needing to show the constructor for objects."

@jzaefferer
Copy link
Member

I don't know how to solve this. Even if we output the constructor, with the code being the same, it won't help figuring out why the test failed. This is all I managed to produce: http://bassistance.de/i/e49a09.png

Added this to jsDump's object parser:

if ( map.constructor !== Object.prototype.constructor ) {
    ret.push( "constructor: " + QUnit.jsDump.parse( map.constructor.toString() ) );
}

If anyone else has an idea, I'd reopen, until then, won't fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants