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

Array equality fails #27

Closed
rdw opened this Issue Aug 8, 2010 · 3 comments

Comments

2 participants
@rdw
Copy link

rdw commented Aug 8, 2010

The following assertion fails, and shouldn't. :)

equals(["a"], ["a"], "arrayfail");

Here's a complete HTML file in case that makes it easier:

<html>
<head>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  <link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
  <script type="text/javascript" src="qunit.js"></script>
</head>
<body>
    <h1 id="qunit-header">Repro</h1>
    <h2 id="qunit-banner"></h2>
    <h2 id="qunit-userAgent"></h2>
    <ol id="qunit-tests"></ol>
<script>
    $(document).ready(function(){
        test("array equality", function() {
            expect(1);
            equals(["a"], ["a"], "a=a");
        });
    });
    </script>

</body>
</html>
@rdw

This comment has been minimized.

Copy link
Author

rdw commented Aug 8, 2010

I realize that ["a"] == ["a"] evaluates to false, so qunit is just passing along whatever design decision lead to that situation in the javascript language. But it seems that people are going to want to make assertions about the value of arrays in the test suite (as I did).

@jzaefferer

This comment has been minimized.

Copy link
Member

jzaefferer commented Aug 8, 2010

Use deepEqual (formerlay same) to compare arrays. The equal (formerly equals) assertion only compares references in this case.

@rdw

This comment has been minimized.

Copy link
Author

rdw commented Aug 9, 2010

Derp, thanks! Shows me what good comes of coding at 3am.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.