DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: set ts=8 sw=4 et tw=99:
 *
 * This tests user-specified (via JSExtendedClass) equality operations on
 * trace.
 */

#include "tests.h"
#include "jsobj.h"

static JSBool
my_Equality(JSContext *cx, JSObject *obj, const jsval *, JSBool *bp)
{
    *bp = JS_TRUE;
    return JS_TRUE;
}

js::Class TestExtendedEq_JSClass = {
    "TestExtendedEq",
    0,
    JS_PropertyStub,       /* addProperty */
    JS_PropertyStub,       /* delProperty */
    JS_PropertyStub,       /* getProperty */
    JS_StrictPropertyStub, /* setProperty */
    JS_EnumerateStub,
    JS_ResolveStub,
    NULL,                  /* convert */
    NULL,                  /* finalize */
    NULL,                  /* checkAccess */
    NULL,                  /* call        */
    NULL,                  /* construct   */
    NULL,                  /* hasInstance */
    NULL,                  /* mark        */
    {
        my_Equality,
        NULL,              /* outerObject    */
        NULL,              /* innerObject    */
        NULL,              /* iteratorObject */
        NULL,              /* wrappedObject  */
    }
};

BEGIN_TEST(testExtendedEq_bug530489)
{
    JSClass *clasp = (JSClass *) &TestExtendedEq_JSClass;

    CHECK(JS_InitClass(cx, global, global, clasp, NULL, 0, NULL, NULL, NULL, NULL));

    CHECK(JS_DefineObject(cx, global, "obj1", clasp, NULL, 0));
    CHECK(JS_DefineObject(cx, global, "obj2", clasp, NULL, 0));

    jsval v;
    EVAL("(function() { var r; for (var i = 0; i < 10; ++i) r = obj1 == obj2; return r; })()", &v);
    CHECK_SAME(v, JSVAL_TRUE);
    return true;
}
END_TEST(testExtendedEq_bug530489)