Changeset 15474 in webkit for trunk/JavaScriptCore/API/testapi.c


Ignore:
Timestamp:
Jul 16, 2006, 7:00:40 PM (19 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


  • Change getProperty* to return undefined, rather than NULL, for missing properties, since that's what the spec says. Also added exception out parameters to the *Index functions, because they can call through to the regular functions, which can throw for custom objects.
  • API/JSObjectRef.cpp: (JSObjectGetProperty): (JSObjectGetPropertyAtIndex): (JSObjectSetPropertyAtIndex):
  • API/JSObjectRef.h:
  • API/testapi.c: (main):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/testapi.c

    r15473 r15474  
    116116        || JSStringIsEqualToUTF8CString(propertyName, "cantFind")
    117117        || JSStringIsEqualToUTF8CString(propertyName, "myPropertyName")
    118         || JSStringIsEqualToUTF8CString(propertyName, "hasPropertyLie")) {
     118        || JSStringIsEqualToUTF8CString(propertyName, "hasPropertyLie")
     119        || JSStringIsEqualToUTF8CString(propertyName, "0")) {
    119120        return true;
    120121    }
     
    138139    if (JSStringIsEqualToUTF8CString(propertyName, "cantFind")) {
    139140        return JSValueMakeUndefined();
     141    }
     142   
     143    if (JSStringIsEqualToUTF8CString(propertyName, "0")) {
     144        *exception = JSValueMakeNumber(1);
     145        return JSValueMakeNumber(1);
    140146    }
    141147   
     
    415421    assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(1), &exception));
    416422    assert(exception);
     423   
     424    exception = NULL;
     425    JSObjectGetPropertyAtIndex(context, myObject, 0, &exception);
     426    assert(1 == JSValueToNumber(context, exception, NULL));
    417427
    418428    assertEqualsAsBoolean(jsUndefined, false);
     
    525535   
    526536    JSStringRef array = JSStringCreateWithUTF8CString("Array");
    527     v = JSObjectGetProperty(context, globalObject, array, NULL);
    528     assert(v);
    529     JSObjectRef arrayConstructor = JSValueToObject(context, v, NULL);
     537    JSObjectRef arrayConstructor = JSValueToObject(context, JSObjectGetProperty(context, globalObject, array, NULL), NULL);
    530538    JSStringRelease(array);
    531539    result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL);
    532540    assert(result);
     541    assert(JSValueIsObject(result));
    533542    assert(JSValueIsInstanceOfConstructor(context, result, arrayConstructor, NULL));
    534543    assert(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull(), arrayConstructor, NULL));
    535    
     544
     545    o = JSValueToObject(context, result, NULL);
     546    exception = NULL;
     547    assert(JSValueIsUndefined(JSObjectGetPropertyAtIndex(context, o, 0, &exception)));
     548    assert(!exception);
     549   
     550    JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber(1), &exception);
     551    assert(!exception);
     552   
     553    exception = NULL;
     554    assert(1 == JSValueToNumber(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception), &exception));
     555    assert(!exception);
     556
    536557    JSStringRef functionBody;
    537558    JSObjectRef function;
     
    543564    assert(JSValueIsObject(exception));
    544565    v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line, NULL);
    545     assert(v);
    546566    assertEqualsAsNumber(v, 2); // FIXME: Lexer::setCode bumps startingLineNumber by 1 -- we need to change internal callers so that it doesn't have to (saying '0' to mean '1' in the API would be really confusing -- it's really confusing internally, in fact)
    547567    JSStringRelease(functionBody);
     
    619639    v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL);
    620640    assert(JSValueIsEqual(context, v, o, NULL));
     641   
     642   
    621643   
    622644    char* scriptUTF8 = createStringWithContentsOfFile("testapi.js");
Note: See TracChangeset for help on using the changeset viewer.