Changeset 26688 in webkit for trunk/JavaScriptCore/API
- Timestamp:
- Oct 16, 2007, 4:25:33 PM (18 years ago)
- Location:
- trunk/JavaScriptCore/API
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSNode.c
r21131 r26688 30 30 #include "NodeList.h" 31 31 #include "UnusedParam.h" 32 #include < assert.h>32 #include <wtf/Assertions.h> 33 33 34 34 static JSValueRef JSNode_appendChild(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) … … 125 125 UNUSED_PARAM(propertyName); 126 126 Node* node = JSObjectGetPrivate(thisObject); 127 assert(node);127 ASSERT(node); 128 128 return JSNodeList_new(context, NodeList_new(node)); 129 129 } … … 148 148 { 149 149 Node* node = JSObjectGetPrivate(object); 150 assert(node);150 ASSERT(node); 151 151 152 152 Node_ref(node); … … 156 156 { 157 157 Node* node = JSObjectGetPrivate(object); 158 assert(node);158 ASSERT(node); 159 159 160 160 Node_deref(node); -
trunk/JavaScriptCore/API/JSNodeList.c
r21131 r26688 28 28 #include "JSNodeList.h" 29 29 #include "UnusedParam.h" 30 #include < assert.h>30 #include <wtf/Assertions.h> 31 31 32 32 static JSValueRef JSNodeList_item(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) … … 34 34 if (argumentCount > 0) { 35 35 NodeList* nodeList = JSObjectGetPrivate(thisObject); 36 assert(nodeList);36 ASSERT(nodeList); 37 37 Node* node = NodeList_item(nodeList, (unsigned)JSValueToNumber(context, arguments[0], exception)); 38 38 if (node) … … 53 53 54 54 NodeList* nodeList = JSObjectGetPrivate(thisObject); 55 assert(nodeList);55 ASSERT(nodeList); 56 56 return JSValueMakeNumber(context, NodeList_length(nodeList)); 57 57 } … … 65 65 { 66 66 NodeList* nodeList = JSObjectGetPrivate(thisObject); 67 assert(nodeList);67 ASSERT(nodeList); 68 68 double index = JSValueToNumber(context, JSValueMakeString(context, propertyName), exception); 69 69 unsigned uindex = (unsigned)index; … … 80 80 { 81 81 NodeList* nodeList = JSObjectGetPrivate(thisObject); 82 assert(nodeList);82 ASSERT(nodeList); 83 83 84 84 NodeList_ref(nodeList); … … 88 88 { 89 89 NodeList* nodeList = JSObjectGetPrivate(thisObject); 90 assert(nodeList);90 ASSERT(nodeList); 91 91 92 92 NodeList_deref(nodeList); -
trunk/JavaScriptCore/API/minidom.c
r21342 r26688 26 26 27 27 #include "JSNode.h" 28 #include <wtf/Assertions.h> 28 29 #include <wtf/UnusedParam.h> 29 30 … … 103 104 buffer_capacity *= 2; 104 105 buffer = (char*)realloc(buffer, buffer_capacity); 105 assert(buffer);106 ASSERT(buffer); 106 107 } 107 108 108 assert(buffer_size < buffer_capacity);109 ASSERT(buffer_size < buffer_capacity); 109 110 } 110 111 fclose(f); -
trunk/JavaScriptCore/API/testapi.c
r25257 r26688 26 26 27 27 #include "JavaScriptCore.h" 28 #include <assert.h>29 28 #include <math.h> 30 #include < setjmp.h>29 #include <wtf/Assertions.h> 31 30 #include <wtf/UnusedParam.h> 32 31 … … 320 319 { 321 320 if (TestInitializeFinalize) { 322 assert((void*)1 == JSObjectGetPrivate(object));321 ASSERT((void*)1 == JSObjectGetPrivate(object)); 323 322 JSObjectSetPrivate(object, (void*)2); 324 323 } … … 329 328 { 330 329 if (TestInitializeFinalize) { 331 assert((void*)4 == JSObjectGetPrivate(object));330 ASSERT((void*)4 == JSObjectGetPrivate(object)); 332 331 Base_didFinalize = true; 333 332 } … … 396 395 { 397 396 if (TestInitializeFinalize) { 398 assert((void*)2 == JSObjectGetPrivate(object));397 ASSERT((void*)2 == JSObjectGetPrivate(object)); 399 398 JSObjectSetPrivate(object, (void*)3); 400 399 } … … 404 403 { 405 404 if (TestInitializeFinalize) { 406 assert((void*)3 == JSObjectGetPrivate(object));405 ASSERT((void*)3 == JSObjectGetPrivate(object)); 407 406 JSObjectSetPrivate(object, (void*)4); 408 407 } … … 458 457 { 459 458 UNUSED_PARAM(object); 460 assert(context);459 ASSERT(context); 461 460 } 462 461 … … 466 465 { 467 466 JSObjectRef o = JSObjectMake(context, Derived_class(context), (void*)1); 468 assert(JSObjectGetPrivate(o) == (void*)3);467 ASSERT(JSObjectGetPrivate(o) == (void*)3); 469 468 } 470 469 … … 482 481 TestInitializeFinalize = false; 483 482 484 assert(Base_didFinalize);483 ASSERT(Base_didFinalize); 485 484 486 485 JSClassDefinition globalObjectClassDefinition = kJSClassDefinitionEmpty; … … 490 489 491 490 JSObjectRef globalObject = JSContextGetGlobalObject(context); 492 assert(JSValueIsObject(context, globalObject));491 ASSERT(JSValueIsObject(context, globalObject)); 493 492 494 493 JSValueRef jsUndefined = JSValueMakeUndefined(context); … … 536 535 JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString(context, jsCFEmptyIStringWithCharacters); 537 536 538 assert(JSValueGetType(context, jsUndefined) == kJSTypeUndefined);539 assert(JSValueGetType(context, jsNull) == kJSTypeNull);540 assert(JSValueGetType(context, jsTrue) == kJSTypeBoolean);541 assert(JSValueGetType(context, jsFalse) == kJSTypeBoolean);542 assert(JSValueGetType(context, jsZero) == kJSTypeNumber);543 assert(JSValueGetType(context, jsOne) == kJSTypeNumber);544 assert(JSValueGetType(context, jsOneThird) == kJSTypeNumber);545 assert(JSValueGetType(context, jsEmptyString) == kJSTypeString);546 assert(JSValueGetType(context, jsOneString) == kJSTypeString);547 assert(JSValueGetType(context, jsCFString) == kJSTypeString);548 assert(JSValueGetType(context, jsCFStringWithCharacters) == kJSTypeString);549 assert(JSValueGetType(context, jsCFEmptyString) == kJSTypeString);550 assert(JSValueGetType(context, jsCFEmptyStringWithCharacters) == kJSTypeString);537 ASSERT(JSValueGetType(context, jsUndefined) == kJSTypeUndefined); 538 ASSERT(JSValueGetType(context, jsNull) == kJSTypeNull); 539 ASSERT(JSValueGetType(context, jsTrue) == kJSTypeBoolean); 540 ASSERT(JSValueGetType(context, jsFalse) == kJSTypeBoolean); 541 ASSERT(JSValueGetType(context, jsZero) == kJSTypeNumber); 542 ASSERT(JSValueGetType(context, jsOne) == kJSTypeNumber); 543 ASSERT(JSValueGetType(context, jsOneThird) == kJSTypeNumber); 544 ASSERT(JSValueGetType(context, jsEmptyString) == kJSTypeString); 545 ASSERT(JSValueGetType(context, jsOneString) == kJSTypeString); 546 ASSERT(JSValueGetType(context, jsCFString) == kJSTypeString); 547 ASSERT(JSValueGetType(context, jsCFStringWithCharacters) == kJSTypeString); 548 ASSERT(JSValueGetType(context, jsCFEmptyString) == kJSTypeString); 549 ASSERT(JSValueGetType(context, jsCFEmptyStringWithCharacters) == kJSTypeString); 551 550 552 551 JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL); … … 559 558 // Conversions that throw exceptions 560 559 exception = NULL; 561 assert(NULL == JSValueToObject(context, jsNull, &exception));562 assert(exception);560 ASSERT(NULL == JSValueToObject(context, jsNull, &exception)); 561 ASSERT(exception); 563 562 564 563 exception = NULL; … … 566 565 // causing a build break with -Wshorten-64-to-32 enabled. The issue is known by the appropriate team. 567 566 // After that's resolved, we can remove these casts 568 assert(isnan((float)JSValueToNumber(context, jsObjectNoProto, &exception)));569 assert(exception);570 571 exception = NULL; 572 assert(!JSValueToStringCopy(context, jsObjectNoProto, &exception));573 assert(exception);574 575 assert(JSValueToBoolean(context, myObject));576 577 exception = NULL; 578 assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(context, 1), &exception));579 assert(exception);567 ASSERT(isnan((float)JSValueToNumber(context, jsObjectNoProto, &exception))); 568 ASSERT(exception); 569 570 exception = NULL; 571 ASSERT(!JSValueToStringCopy(context, jsObjectNoProto, &exception)); 572 ASSERT(exception); 573 574 ASSERT(JSValueToBoolean(context, myObject)); 575 576 exception = NULL; 577 ASSERT(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(context, 1), &exception)); 578 ASSERT(exception); 580 579 581 580 exception = NULL; 582 581 JSObjectGetPropertyAtIndex(context, myObject, 0, &exception); 583 assert(1 == JSValueToNumber(context, exception, NULL));582 ASSERT(1 == JSValueToNumber(context, exception, NULL)); 584 583 585 584 assertEqualsAsBoolean(jsUndefined, false); … … 610 609 assertEqualsAsNumber(jsCFEmptyString, 0); 611 610 assertEqualsAsNumber(jsCFEmptyStringWithCharacters, 0); 612 assert(sizeof(JSChar) == sizeof(UniChar));611 ASSERT(sizeof(JSChar) == sizeof(UniChar)); 613 612 614 613 assertEqualsAsCharactersPtr(jsUndefined, "undefined"); … … 640 639 assertEqualsAsUTF8String(jsCFEmptyStringWithCharacters, ""); 641 640 642 assert(JSValueIsStrictEqual(context, jsTrue, jsTrue));643 assert(!JSValueIsStrictEqual(context, jsOne, jsOneString));644 645 assert(JSValueIsEqual(context, jsOne, jsOneString, NULL));646 assert(!JSValueIsEqual(context, jsTrue, jsFalse, NULL));641 ASSERT(JSValueIsStrictEqual(context, jsTrue, jsTrue)); 642 ASSERT(!JSValueIsStrictEqual(context, jsOne, jsOneString)); 643 644 ASSERT(JSValueIsEqual(context, jsOne, jsOneString, NULL)); 645 ASSERT(!JSValueIsEqual(context, jsTrue, jsFalse, NULL)); 647 646 648 647 CFStringRef cfJSString = JSStringCopyCFString(kCFAllocatorDefault, jsCFIString); 649 648 CFStringRef cfJSEmptyString = JSStringCopyCFString(kCFAllocatorDefault, jsCFEmptyIString); 650 assert(CFEqual(cfJSString, cfString));651 assert(CFEqual(cfJSEmptyString, cfEmptyString));649 ASSERT(CFEqual(cfJSString, cfString)); 650 ASSERT(CFEqual(cfJSEmptyString, cfEmptyString)); 652 651 CFRelease(cfJSString); 653 652 CFRelease(cfJSEmptyString); … … 659 658 JSValueProtect(context, jsGlobalValue); 660 659 JSGarbageCollect(context); 661 assert(JSValueIsObject(context, jsGlobalValue));660 ASSERT(JSValueIsObject(context, jsGlobalValue)); 662 661 JSValueUnprotect(context, jsGlobalValue); 663 662 664 663 JSStringRef goodSyntax = JSStringCreateWithUTF8CString("x = 1;"); 665 664 JSStringRef badSyntax = JSStringCreateWithUTF8CString("x := 1;"); 666 assert(JSCheckScriptSyntax(context, goodSyntax, NULL, 0, NULL));667 assert(!JSCheckScriptSyntax(context, badSyntax, NULL, 0, NULL));665 ASSERT(JSCheckScriptSyntax(context, goodSyntax, NULL, 0, NULL)); 666 ASSERT(!JSCheckScriptSyntax(context, badSyntax, NULL, 0, NULL)); 668 667 669 668 JSValueRef result; … … 673 672 674 673 result = JSEvaluateScript(context, goodSyntax, NULL, NULL, 1, NULL); 675 assert(result);676 assert(JSValueIsEqual(context, result, jsOne, NULL));674 ASSERT(result); 675 ASSERT(JSValueIsEqual(context, result, jsOne, NULL)); 677 676 678 677 exception = NULL; 679 678 result = JSEvaluateScript(context, badSyntax, NULL, NULL, 1, &exception); 680 assert(!result);681 assert(JSValueIsObject(context, exception));679 ASSERT(!result); 680 ASSERT(JSValueIsObject(context, exception)); 682 681 683 682 JSStringRef array = JSStringCreateWithUTF8CString("Array"); … … 685 684 JSStringRelease(array); 686 685 result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL); 687 assert(result);688 assert(JSValueIsObject(context, result));689 assert(JSValueIsInstanceOfConstructor(context, result, arrayConstructor, NULL));690 assert(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull(context), arrayConstructor, NULL));686 ASSERT(result); 687 ASSERT(JSValueIsObject(context, result)); 688 ASSERT(JSValueIsInstanceOfConstructor(context, result, arrayConstructor, NULL)); 689 ASSERT(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull(context), arrayConstructor, NULL)); 691 690 692 691 o = JSValueToObject(context, result, NULL); 693 692 exception = NULL; 694 assert(JSValueIsUndefined(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception)));695 assert(!exception);693 ASSERT(JSValueIsUndefined(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception))); 694 ASSERT(!exception); 696 695 697 696 JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber(context, 1), &exception); 698 assert(!exception);699 700 exception = NULL; 701 assert(1 == JSValueToNumber(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception), &exception));702 assert(!exception);697 ASSERT(!exception); 698 699 exception = NULL; 700 ASSERT(1 == JSValueToNumber(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception), &exception)); 701 ASSERT(!exception); 703 702 704 703 JSStringRef functionBody; … … 708 707 functionBody = JSStringCreateWithUTF8CString("rreturn Array;"); 709 708 JSStringRef line = JSStringCreateWithUTF8CString("line"); 710 assert(!JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception));711 assert(JSValueIsObject(context, exception));709 ASSERT(!JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception)); 710 ASSERT(JSValueIsObject(context, exception)); 712 711 v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line, NULL); 713 712 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) … … 719 718 function = JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception); 720 719 JSStringRelease(functionBody); 721 assert(!exception);722 assert(JSObjectIsFunction(context, function));720 ASSERT(!exception); 721 ASSERT(JSObjectIsFunction(context, function)); 723 722 v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL); 724 assert(v);725 assert(JSValueIsEqual(context, v, arrayConstructor, NULL));723 ASSERT(v); 724 ASSERT(JSValueIsEqual(context, v, arrayConstructor, NULL)); 726 725 727 726 exception = NULL; 728 727 function = JSObjectMakeFunction(context, NULL, 0, NULL, jsEmptyIString, NULL, 0, &exception); 729 assert(!exception);728 ASSERT(!exception); 730 729 v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, &exception); 731 assert(v && !exception);732 assert(JSValueIsUndefined(context, v));730 ASSERT(v && !exception); 731 ASSERT(JSValueIsUndefined(context, v)); 733 732 734 733 exception = NULL; … … 738 737 functionBody = JSStringCreateWithUTF8CString("return foo;"); 739 738 function = JSObjectMakeFunction(context, foo, 1, argumentNames, functionBody, NULL, 1, &exception); 740 assert(function && !exception);739 ASSERT(function && !exception); 741 740 JSValueRef arguments[] = { JSValueMakeNumber(context, 2) }; 742 741 v = JSObjectCallAsFunction(context, function, NULL, 1, arguments, &exception); … … 753 752 JSStringRelease(print); 754 753 755 assert(!JSObjectSetPrivate(printFunction, (void*)1));756 assert(!JSObjectGetPrivate(printFunction));754 ASSERT(!JSObjectSetPrivate(printFunction, (void*)1)); 755 ASSERT(!JSObjectGetPrivate(printFunction)); 757 756 758 757 JSStringRef myConstructorIString = JSStringCreateWithUTF8CString("MyConstructor"); … … 761 760 JSStringRelease(myConstructorIString); 762 761 763 assert(!JSObjectSetPrivate(myConstructor, (void*)1));764 assert(!JSObjectGetPrivate(myConstructor));762 ASSERT(!JSObjectSetPrivate(myConstructor, (void*)1)); 763 ASSERT(!JSObjectGetPrivate(myConstructor)); 765 764 766 765 string = JSStringCreateWithUTF8CString("Derived"); … … 778 777 JSPropertyNameArrayGetNameAtIndex(nameArray, count); 779 778 JSPropertyNameArrayRelease(nameArray); 780 assert(count == 1); // jsCFString should not be enumerated779 ASSERT(count == 1); // jsCFString should not be enumerated 781 780 782 781 JSClassDefinition nullDefinition = kJSClassDefinitionEmpty; … … 793 792 JSStringRelease(functionBody); 794 793 v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL); 795 assert(JSValueIsEqual(context, v, globalObject, NULL));794 ASSERT(JSValueIsEqual(context, v, globalObject, NULL)); 796 795 v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL); 797 assert(JSValueIsEqual(context, v, o, NULL));796 ASSERT(JSValueIsEqual(context, v, o, NULL)); 798 797 799 798 char* scriptUTF8 = createStringWithContentsOfFile("testapi.js"); … … 849 848 buffer_capacity *= 2; 850 849 buffer = (char*)realloc(buffer, buffer_capacity); 851 assert(buffer);850 ASSERT(buffer); 852 851 } 853 852 854 assert(buffer_size < buffer_capacity);853 ASSERT(buffer_size < buffer_capacity); 855 854 } 856 855 fclose(f);
Note:
See TracChangeset
for help on using the changeset viewer.